Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to name html:form tag in sturts

 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Merrill

one more doubt,can i have more tahn one <html:form> tag in jsp page,
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic