Class FormTool
- java.lang.Object
-
- org.apache.velocity.tools.struts.FormTool
-
public class FormTool extends java.lang.ObjectView tool to work with HTML forms in Struts.
Template example(s): <input type="hidden" name="$form.tokenName" value="$form.token"> <input type="submit" name="$form.cancelName" value="Cancel"> Toolbox configuration: <tool> <key>form</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.FormTool</class> </tool>
This tool should only be used in the request scope.
- Since:
- VelocityTools 1.0
- Version:
- $Id: FormTool.java 477914 2006-11-21 21:52:11Z henning $
- Author:
- Gabe Sidler
-
-
Constructor Summary
Constructors Constructor Description FormTool()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.struts.action.ActionFormgetBean()Returns the form bean associated with this action mapping.java.lang.StringgetCancelName()Returns the query parameter name under which a cancel button press must be reported if form validation is to be skipped.java.lang.StringgetName()Returns the form bean name associated with this action mapping.java.lang.StringgetToken()Returns the transaction control token for this session ornullif no token exists.java.lang.StringgetTokenName()Returns the query parameter name under which a transaction token must be reported.voidinit(java.lang.Object obj)Initializes this tool.
-
-
-
Method Detail
-
init
public void init(java.lang.Object obj)
Initializes this tool.- Parameters:
obj- the current ViewContext- Throws:
java.lang.IllegalArgumentException- if the param is not a ViewContext
-
getBean
public org.apache.struts.action.ActionForm getBean()
Returns the form bean associated with this action mapping.
This is a convenience method. The form bean is automatically available in the Velocity context under the name defined in the Struts configuration.
If the form bean is used repeatedly, it is recommended to create a local variable referencing the bean rather than calling getBean() multiple times.
Example: #set ($defaults = $form.bean) <input type="text" name="username" value="$defaults.username">
- Returns:
- the
ActionFormassociated with this request ornullif there is no form bean associated with this mapping
-
getName
public java.lang.String getName()
Returns the form bean name associated with this action mapping.
- Returns:
- the name of the ActionForm associated with this request or
nullif there is no form bean associated with this mapping
-
getCancelName
public java.lang.String getCancelName()
Returns the query parameter name under which a cancel button press must be reported if form validation is to be skipped.
This is the value of
org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY
-
getToken
public java.lang.String getToken()
Returns the transaction control token for this session ornullif no token exists.
-
getTokenName
public java.lang.String getTokenName()
Returns the query parameter name under which a transaction token must be reported. This is the value of
org.apache.struts.taglib.html.Constants.TOKEN_KEY
-
-