public class FormTool
extends java.lang.Object
View 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.
| Modifier and Type | Field and Description |
|---|---|
protected javax.servlet.http.HttpServletRequest |
request
A reference to the HtttpServletRequest.
|
protected javax.servlet.http.HttpSession |
session
A reference to the HtttpSession.
|
| Constructor and Description |
|---|
FormTool()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.struts.action.ActionForm |
getBean()
Returns the form bean associated with this action mapping.
|
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.
|
java.lang.String |
getName()
Returns the form bean name associated with this action mapping.
|
java.lang.String |
getToken()
Returns the transaction control token for this session or
null if no token exists. |
java.lang.String |
getTokenName()
Returns the query parameter name under which a transaction token
must be reported.
|
void |
init(java.lang.Object obj)
Initializes this tool.
|
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpSession session
public FormTool()
public void init(java.lang.Object obj)
obj - the current ViewContextjava.lang.IllegalArgumentException - if the param is not a ViewContextpublic 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">
ActionForm associated with this request or
null if there is no form bean associated with this mappingpublic java.lang.String getName()
Returns the form bean name associated with this action mapping.
null if there is no form bean associated with this mappingpublic 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
public java.lang.String getToken()
null if no token exists.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
Copyright (c) 2003-2007 Apache Software Foundation