is nesting of struts html:form valid & how it works

Discussions

Web tier: servlets, JSP, Web frameworks: is nesting of struts html:form valid & how it works

  1. Hi
    in my dooffice.jsp page, the user must select proper location and proper area.So i have to open an popup which lists all locations and one for all area's. for both of this i have following code in dooffice.jsp

    CODESEGMENT1 starts:-----

    <html:form action="addeditoffice">
    <input type="hidden" name="reqCode" value="p">

    <html:text name="officeForm" property="location" disabled="true"/>
    <html:submit alt = "Select a location" tabindex="0" onclick="this.form.elements['reqCode'].value='getlocation';return openpopup(this.form, '', '250', '220', event);" value="?"/>

    <html:text name="officeForm" property="areaName"/>
    <html:submit alt = "Select the Area" tabindex="1" onclick="this.form.elements['reqCode'].value='getarea';return openpopup(this.form, '', '250', '220', event);" value="?"/>

    </html:form>

    CODESEGMENT1 ends:-----

    above code works properly.no problem in that
    After the user selects area & location, the user would fill the address,telephone number etc.
    i need to store area,location,address,telephone etc in database.
    so i have nested CODESEGMENT1 inside another set of html:form like below

    MAINCODESEGMENT starts:----

    <html:form action="addeditoffice" method="post">
    CODESEGMENT1.....
    <html:text name="officeForm" property="address1"/>
    <html:text name="officeForm" property="phone1"/>

    <input type="hidden" name="saveEdit" value="saveedit">
    <html:submit alt="edit office" property="action" value="edit" onclick="javascript:return editoffice(document.forms[0]);"/>

    MAINCODESEGMENT ends----

    but when i click the submit button, i cannot get the hidden variable nameed saveEdit in my Action class,instead iam getting the hidden variable reqCode .I need to decide whether to update or insert a record based on the value of hidden variable saveEdit.The javascript function editoffice() just submits the form.

    what can be the reason?
    How does an html:form nested inside the other work?

    thanks
  2. You can't nest <form statements reliably in HTML, so you can't in JSP either.
    The other problem you run into is which ActionForm are you going to use?