File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Html:form

 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cam we put attribute NAME in html:form like

<html:form name="form1">
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not if you're using version 1.2.9 or above. The name attribute has been removed from these versions.

Even if you're using an earlier version, I wouldn't recommend using the name attribute of the <html:form> tag. It's completely redundant. You have already specified the name and type in the action mapping in your struts-config.xml file. There's no need to specify it again here.
 
Neerav Narielwala
Ranch Hand
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form-related tags consist of the <form> tag itself plus all tags that must be used inside it. For example, the <text> and <password> tags are form-related tags because it does not make sense if they are not placed inside a form.

The <form> Tag
The <form> tag generates an HTML form. You must follow a number of rules to use this tag.

First and foremost, a <form> tag must contain an action attribute, the only required attribute for this tag. Without an action attribute, your JSP page will throw an exception. Then, you must assign a valid value to this action attribute. A valid value is the path in any of the <action> elements in the <action-mappings> element in the application's Struts configuration file. Also, the corresponding <action> element must have a name attribute whose value is the name of a form bean.

For example, if you have this <form> tag:

<html:form action="/login" >

the <action-mappings> element of your Struts configuration file must have this <action> element in bold:

<action-mappings>
<action path="/login"
type="com.javapro.struts.LoginAction"
name="loginForm"
scope="request"
input="/login.jsp">
<forward name="success" path="/mainMenu.jsp"/>
</action>
.
.
.
</action-mappings>

This is to say that a form tag is associated with a form bean.

Another rule to follow: Any tag contained within the <form> tag to receive user input (<text>, <password>, <hidden>, <textarea>, <radio>, <checkbox>, <select> must have its property value assigned to a property in the associated form bean. For instance, if you have a <text> tag whose property is assigned the value "userName", the associated form bean must also have a property called "userName". The value entered into this <text> tag will then be used to populate the userName property of the form bean.
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I have six buttons for each I have to call different action.How can I call from the same page?
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I have six buttons for each I have to call different action.How can I call from the same page?
 
Ingoba Ningthoujam
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I have six buttons for each I have to call different action.How can I call from the same page?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While there are ways to have different buttons call different actions, I'd recommend that you stick with a single action for the form and put logic in that action to branch depending on which button was pressed.

An <html:submit> tag will send whatever is in the value attribute to the server. You can use this value to determine what button was pressed. Example: Suppose you want three buttons: add, delete, and edit. You then add a property called "action" to your ActionForm, and put the following three tags in your JSP:

Then in the execute method of your Action class, you put the following logic:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic