File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes is nesting of struts html:form valid & how it works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "is nesting of struts html:form valid & how it works" Watch "is nesting of struts html:form valid & how it works" New topic

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

Vilpesh Mistry
Ranch Hand

Joined: May 27, 2003
Posts: 62

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

NOTE:i have removed every lessthan and greaterthan sign from struts/html tags and also changed to onclickee instead of onclick

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" onclickee="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" onclickee="this.form.elements['reqCode'].value='getarea';return openpopup(this.form, '', '250', '220', event);" value="?"/


CODESEGMENT1 ends:-----

above code works 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


html:form action="addeditoffice" method="post"
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" onclickee="javascript:return editoffice(document.forms[0]);"/

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?


Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Don't nest forms. It doesn't make any sense. And if you're doing XHTML, it won't validate.

John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Yeah, I don't think it works under struts anyway and rightly so. You should never nest forms.

Struts also doesn't do pop-ups so what you can do is dump a bean on the session with the data from you "inner form" if you need to
[ December 09, 2004: Message edited by: John Smith ]
I agree. Here's the link:
subject: is nesting of struts html:form valid & how it works
It's not a secret anymore!