|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.tag.StripesTagSupport
net.sourceforge.stripes.tag.HtmlTagSupport
net.sourceforge.stripes.tag.ErrorsTag
public class ErrorsTag
The errors tag has two modes, one where it displays all validation errors in a list and a second mode when there is a single enclosed field-error tag that has no name attribute in which case this tag iterates over the body, displaying each error in turn in place of the field-error tag.
In the first mode, where the default output is used, it is possible to change the output for the entire application using a set of resources in the error messages bundle (StripesResources.properties unless you have configured another). If the properties are undefined, the tag will output the text "Validation Errors" in a div with css class errorHeader, then output an unordered list of error messages. The following four resource strings (shown with their default values) can be modified to create different default output:
The errors tag can also be used to display errors for a single field by supplying it with a 'field' attribute which matches the name of a field on the page. In this case the tag will display only if errors exist for the named field. In this mode the tag will first look for resources named:
If the fieldErrors
resources cannot be found, the tag will default to using the
same resources and defaults as when displaying for all fields.
Similar to the above, field specific, manner of display the errors tag can also be used
to output only errors not associated with a field, i.e. global errors. This is done by setting
the globalErrorsOnly
attribute to true.
This tag has several ways of being attached to the errors of a specific action request. If the tag is inside a form tag, it will display only errors that are associated with that form. If supplied with an 'action' attribute, it will display errors only errors associated with a request to that URL. Finally, if neither is the case, it will always display as described in the paragraph above.
Field Summary | |
---|---|
static String |
DEFAULT_FOOTER
The footer that will be emitted if no footer is defined in the resource bundle. |
static String |
DEFAULT_HEADER
The header that will be emitted if no header is defined in the resource bundle. |
Fields inherited from class net.sourceforge.stripes.tag.StripesTagSupport |
---|
pageContext, parentTag |
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
---|
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
---|
EVAL_BODY_AGAIN |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
---|
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
---|---|
ErrorsTag()
|
Method Summary | |
---|---|
int |
doAfterBody()
Manages iteration, running again if there are more errors to display. |
int |
doEndTag()
Output the error list if this was an empty body tag and we're fully controlling output* |
void |
doInitBody()
Sets the context variables for the current error and index |
int |
doStartTag()
Determines if the tag should display errors based on the action that it is displaying for, and then fetches the appropriate list of errors and makes sure it is non-empty. |
String |
getAction()
Returns the value set with setAction(). |
ValidationError |
getCurrentError()
Called by the IndividualErrorTag to fetch the current error from the set being iterated. |
String |
getField()
Gets the value set with setField(). |
protected String |
getResource(ResourceBundle bundle,
String name,
String fallback)
Utility method that is used to lookup the resources used for the errors header, footer, and the strings that go before and after each error. |
boolean |
isFirst()
Returns true if the error displayed is the first matching error. |
boolean |
isGlobalErrorsOnly()
Indicated whether the tag is displaying only global errors. |
boolean |
isLast()
Returns true if the error displayed is the last matching error. |
void |
setAction(String action)
Sets the (optional) action of the form to display errors for, if they exist. |
void |
setBeanclass(Object beanclass)
Sets the action attribute by figuring out what ActionBean class is identified and then in turn finding out the appropriate URL for the ActionBean. |
void |
setField(String field)
Sets the (optional) name of a field to display errors for, if errors exist. |
void |
setGlobalErrorsOnly(boolean globalErrorsOnly)
Tells the tag to display (or not) only global errors and no field level errors. |
Methods inherited from class net.sourceforge.stripes.tag.HtmlTagSupport |
---|
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 |
Methods inherited from class net.sourceforge.stripes.tag.StripesTagSupport |
---|
getActionBeanType, getActionBeanUrl, getPageContext, getParent, getParentTag, getTagStack, popPageContextAttributes, pushPageContextAttributes, setPageContext, setParent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.servlet.jsp.tagext.BodyTag |
---|
setBodyContent |
Methods inherited from interface javax.servlet.jsp.tagext.Tag |
---|
getParent, release, setPageContext, setParent |
Field Detail |
---|
public static final String DEFAULT_HEADER
public static final String DEFAULT_FOOTER
Constructor Detail |
---|
public ErrorsTag()
Method Detail |
---|
public ValidationError getCurrentError()
public boolean isFirst()
public boolean isLast()
public void setAction(String action)
public String getAction()
public void setBeanclass(Object beanclass) throws StripesJspException
beanclass
- the FQN of an ActionBean class, or a Class object for one.
StripesJspException
public void setField(String field)
public String getField()
public boolean isGlobalErrorsOnly()
public void setGlobalErrorsOnly(boolean globalErrorsOnly)
public int doStartTag() throws JspException
doStartTag
in interface Tag
doStartTag
in class StripesTagSupport
JspException
public void doInitBody() throws JspException
doInitBody
in interface BodyTag
JspException
public int doAfterBody() throws JspException
doAfterBody
in interface IterationTag
JspException
public int doEndTag() throws JspException
doEndTag
in interface Tag
doEndTag
in class StripesTagSupport
JspException
protected String getResource(ResourceBundle bundle, String name, String fallback)
bundle
- the bundle to look up the resource fromname
- the name of the resource to lookup (prefixes will be added)fallback
- a value to return if no resource can be found
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |