permaculture playing cards*
The moose likes Struts and the fly likes How to name html:form tag in sturts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to name html:form tag in sturts" Watch "How to name html:form tag in sturts" New topic
Author

How to name html:form tag in sturts

sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Hi all,

before using struts i used to give names for Form tag

like <form name="myform1" action="" method="Post">
controls...
</form>

if a jsp page has more than one form tag ,i can distinguish the control from which form the event is fired..

but in sturts

<html:form name=""> here name refers to formbean

what is the solution to the problem


Thanks
Sreenivas
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Struts automatically assigns a name to every form created by a <html:form> tag. The name it assigns is the name of the ActionForm bean associated with the action specified by the action attribute. Example:

In the struts-config.xml file:

In the JSP:

When Struts renders the above tag into HTML, it will assign the name "myForm" to the form.


Merrill
Consultant, Sima Solutions
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Thanks Merrill

one more doubt,can i have more tahn one <html:form> tag in jsp page,
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, you can. However, if both forms use the same form bean, they will both have the same name. Therefore, if you want to refer to them in JavaScript, you will have to use something other than the name. You could, for example, refer to them as document.forms[0] and document.forms[1].
[ March 07, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to name html:form tag in sturts