Rengasami Ramanujam
Rengasami Ramanujam

Reputation: 1888

Included JSP generates a nested form element in JSF 1.1

I have created a JSP page where we use JSF custom tags. This page includes another JSP page where we defined few more input parameters. Please find the code below

Page 1:

<f:subview id="body">
        <h:form id="page1">
            <h:outputText value="<h2>Data</h2>" escape="false" />
            <jsp:include  page="Page2.jsp" flush="true"></jsp:include>
            <h:commandButton id="button" type="submit" action="#doSomethingBean.doSomething}" 
                value="Submit" title="Submit" alt="Submit"/> 
        </h:form>
        </f:subview>

Page2.jsp :

    <f:verbatim>
           <!-- Content box -->
            <ul class="summaryTable"> 
             <li> <span> 
             </f:verbatim>              
                <h:outputText value="Value: "/> <f:verbatim>Check out sir</span></f:verbatim>   
                <h:outputText value="#{User.userName}" escape="false"/>
            <f:verbatim>                
                </li>
                <li> <span>


         </f:verbatim>           

Generated HTML code:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <body>
    <form id="content:body:page1" method="post" action="/DummyApp/DoSomething.jsp" class="contentBox" enctype="application/x-www-form-urlencoded">

          <h2>Data</h2>

        <form id="content:body:page1:body:page2" method="post" action="/DummyApp/DoSomething.jsp" class="contentBox" enctype="application/x-www-form-urlencoded">

        <ul class="summaryTable"> 
             <li> <span> 
             Check out sir</span> Renga

        </form>

    <input id="content:page1:body:button" type="submit" name="content:page1:body:button" value="Submit" onclick="clearFormHiddenParams(this.form.id);" alt="Submit" title="Submit" class="no-arrow" />

    </form>
    </body>
    </html>

If you see the generated HTML code it is unnecessarily embedding the included file in a form tag. Because of this, whenever I click the submit button is throwing a javascirpt error stating Object not found.

I am using JSF 1.1 and WAS 7 server.

Thanks in advance for the help.

Regards, Renga

Upvotes: 0

Views: 302

Answers (0)

Related Questions