public class FormTag extends HtmlTagSupport implements javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.TryCatchFinally, ParameterizableTag
Form tag for use with the Stripes framework. Supports all of the HTML attributes applicable to the form tag, with one exception: due to JSP attribute naming restrictions accept-charset is specified as acceptcharset (but will be rendered correctly in the output HTML).
pageContext, parentTag
Constructor and Description |
---|
FormTag() |
Modifier and Type | Method and Description |
---|---|
void |
addParameter(java.lang.String name,
java.lang.Object valueOrValues)
Appends a parameter to the "action" attribute of the form tag.
|
protected java.lang.String |
buildAction()
Builds the action attribute, including the context path and any parameters.
|
int |
doAfterBody()
Just returns SKIP_BODY so that the body is included only once.
|
void |
doCatch(java.lang.Throwable throwable)
Rethrows the passed in throwable in all cases.
|
int |
doEndTag()
Writes things out in the following order:
The form open tag
Hidden fields for the form name and source page
The buffered body content
The form close tag
|
void |
doFinally()
Used to ensure that the form is always removed from the tag stack so that there is
never any confusion about tag-parent hierarchies.
|
void |
doInitBody()
No-op method.
|
int |
doStartTag()
Does sanity checks and returns EVAL_BODY_BUFFERED.
|
java.lang.String |
getAccept() |
java.lang.String |
getAcceptcharset() |
java.lang.String |
getAction() |
protected ActionBean |
getActionBean()
Fetches the ActionBean associated with the form if one is present.
|
protected java.lang.Class<? extends ActionBean> |
getActionBeanClass()
Lazily looks up and returns the type of action bean the form will submit to.
|
protected java.lang.String |
getActionBeanUrlBinding()
Get the URL binding for the form's
ActionBean from the ActionResolver . |
java.lang.Object |
getBeanclass()
Corresponding getter for 'beanclass', will always return null.
|
java.lang.String |
getEnctype()
Gets the form encoding.
|
java.lang.String |
getFocus()
Gets the name of the field that should receive focus when the form is rendered.
|
java.lang.String |
getMethod()
Gets the HTTP method to use when the form is submitted.
|
java.lang.String |
getName() |
java.lang.String |
getOnreset() |
java.lang.String |
getOnsubmit() |
java.util.Set<java.lang.String> |
getRegisteredFields()
Gets the set of all field names for which fields have been referred within the form up
until the point of calling this method.
|
java.lang.String |
getTarget() |
boolean |
isPartial()
Gets the flag that indicates if this is a partial form.
|
protected boolean |
isWizard()
Returns true if the ActionBean this form posts to represents a Wizard action bean and
false in all other situations.
|
void |
registerField(InputTagSupport tag)
Used by nested tags to notify the form that a field with the specified name has been
written to the form.
|
void |
setAccept(java.lang.String accept) |
void |
setAcceptcharset(java.lang.String acceptCharset) |
void |
setAction(java.lang.String action)
Sets the action for the form.
|
void |
setBeanclass(java.lang.Object beanclass)
Sets the 'action' attribute by inspecting the bean class provided and asking the current
ActionResolver what the appropriate URL is.
|
void |
setEnctype(java.lang.String enctype)
Sets the form encoding.
|
void |
setFocus(java.lang.String focus)
Sets the name of the field that should receive focus when the form is rendered.
|
protected void |
setFocusOnFieldIfRequired(InputTagSupport tag)
Checks to see if the field should receive focus either because it is the named
field for receiving focus, because it is the first field in the form (and first
field focus was specified), or because it is the first field in error.
|
void |
setMethod(java.lang.String method)
Sets the HTTP method to use when the form is submitted.
|
void |
setName(java.lang.String name) |
void |
setOnreset(java.lang.String onreset) |
void |
setOnsubmit(java.lang.String onsubmit) |
void |
setPartial(boolean partial)
Sets the flag that indicates if this is a partial form.
|
void |
setTarget(java.lang.String target) |
protected void |
writeFieldsPresentHiddenField(javax.servlet.jsp.JspWriter out)
In general writes out a hidden field notifying the server exactly what fields were
present on the page.
|
protected void |
writeWizardFields()
Writes out hidden fields for all fields that are present in the request but are not
explicitly present in this form.
|
evaluateExpression, get, getAccesskey, getAttributes, getBodyContent, getBodyContentAsString, getCssClass, getDir, getId, getLang, getOnblur, getOnchange, getOnclick, getOndblclick, getOnfocus, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnselect, getStyle, getTabindex, getTitle, release, set, setAccesskey, setBodyContent, setClass, setCssClass, setDir, setDynamicAttribute, setId, setLang, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setStyle, setTabindex, setTitle, toString, writeAttributes, writeCloseTag, writeOpenTag, writeSingletonTag
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent
public void setAction(java.lang.String action)
action
- the action path, relative to the root of the web applicationpublic java.lang.String getAction()
protected java.lang.String getActionBeanUrlBinding()
ActionBean
from the ActionResolver
.protected java.lang.Class<? extends ActionBean> getActionBeanClass()
public void setBeanclass(java.lang.Object beanclass) throws StripesJspException
beanclass
- the String FQN of the class, or a Class representing the classStripesJspException
- if the URL cannot be determined for any reason, most likely
because of a mis-spelled class name, or a class that's not an ActionBeanpublic java.lang.Object getBeanclass()
public void setFocus(java.lang.String focus)
public java.lang.String getFocus()
public boolean isPartial()
public void setPartial(boolean partial)
public void setEnctype(java.lang.String enctype)
public java.lang.String getEnctype()
public void setMethod(java.lang.String method)
public java.lang.String getMethod()
public void setAccept(java.lang.String accept)
public java.lang.String getAccept()
public void setAcceptcharset(java.lang.String acceptCharset)
public java.lang.String getAcceptcharset()
public void setName(java.lang.String name)
public java.lang.String getName()
public void setTarget(java.lang.String target)
public java.lang.String getTarget()
public void setOnreset(java.lang.String onreset)
public java.lang.String getOnreset()
public void setOnsubmit(java.lang.String onsubmit)
public java.lang.String getOnsubmit()
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class StripesTagSupport
javax.servlet.jsp.JspException
public void doInitBody() throws javax.servlet.jsp.JspException
doInitBody
in interface javax.servlet.jsp.tagext.BodyTag
javax.servlet.jsp.JspException
public int doAfterBody() throws javax.servlet.jsp.JspException
doAfterBody
in interface javax.servlet.jsp.tagext.IterationTag
javax.servlet.jsp.JspException
public int doEndTag() throws javax.servlet.jsp.JspException
All of this is done in doEndTag to allow form elements to modify the form tag itself if necessary. A prime example of this is the InputFileTag, which needs to ensure that the form method is POST and the enctype is correct.
doEndTag
in interface javax.servlet.jsp.tagext.Tag
doEndTag
in class StripesTagSupport
javax.servlet.jsp.JspException
public void doCatch(java.lang.Throwable throwable) throws java.lang.Throwable
doCatch
in interface javax.servlet.jsp.tagext.TryCatchFinally
java.lang.Throwable
public void doFinally()
doFinally
in interface javax.servlet.jsp.tagext.TryCatchFinally
protected void writeFieldsPresentHiddenField(javax.servlet.jsp.JspWriter out) throws java.io.IOException
In general writes out a hidden field notifying the server exactly what fields were present on the page. Exact behaviour depends upon whether or not the current form is a wizard or not. When the current form is not a wizard this method examines the form tag to determine what fields present in the form might not get submitted to the server (e.g. checkboxes, selects), writes out a hidden field that contains the names of all those fields so that we can detect non-submission when the request comes back.
In the case of a wizard form the value output is the full list of all fields that were present on the page. This is done because the list is used to drive required field validation knowing that in a wizard required fields may be spread across several pages.
In both cases the value is encrypted to stop the user maliciously spoofing the value.
out
- the output writer into which the hidden tag should be writtenjava.io.IOException
- if the writer throws oneprotected ActionBean getActionBean()
protected boolean isWizard()
protected void writeWizardFields() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
public void registerField(InputTagSupport tag)
tag
- the input field tag being registeredprotected void setFocusOnFieldIfRequired(InputTagSupport tag)
tag
- the input tag being registered with the formpublic java.util.Set<java.lang.String> getRegisteredFields()
public void addParameter(java.lang.String name, java.lang.Object valueOrValues)
addParameter
in interface ParameterizableTag
name
- the parameter namevalueOrValues
- the parameter value(s)ParameterizableTag.addParameter(String, Object)
protected java.lang.String buildAction()
? Copyright 2005-2006, Stripes Development Team.