|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.tools.struts.MessageResourcesTool | +--org.apache.velocity.tools.struts.ErrorsTool
View tool to work with the Struts error messages.
Template example(s): #if( $errors.exist() ) <div class="errors"> #foreach( $e in $errors.all ) $e <br> #end </div> #end Toolbox configuration: <tool> <key>errors</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.ErrorsTool</class> </tool>
This tool should only be used in the request scope.
Field Summary | |
protected org.apache.struts.action.ActionErrors |
errors
A reference to the queued action messages. |
Fields inherited from class org.apache.velocity.tools.struts.MessageResourcesTool |
application, locale, request, resources |
Constructor Summary | |
ErrorsTool()
Default constructor. |
Method Summary | |
boolean |
exist()
Returns true if there are action errors queued,
otherwise false . |
boolean |
exist(java.lang.String property)
Returns true if there are action errors queued for the specified category of errors, otherwise false . |
java.util.ArrayList |
get(java.lang.String property)
Returns the set of localized error messages as an java.util.ArrayList of java.lang.String
for all errors queued of the specified category or null
if no error are queued for the specified category. |
java.util.ArrayList |
get(java.lang.String property,
java.lang.String bundle)
Returns the set of localized error messages as an java.util.ArrayList of java.lang.String
for all errors queued of the specified category or null
if no error are queued for the specified category. |
java.util.ArrayList |
getAll()
Returns the set of localized error messages as an java.util.ArrayList of java.lang.String
for all errors queued or null if no errors are queued. |
java.util.ArrayList |
getGlobal()
This a convenience method and the equivalent of $errors.get($errors.globalName) . |
java.lang.String |
getGlobalName()
Returns the default "GLOBAL" category name that can be used for messages that are not associated with a particular property. |
java.lang.String |
getMsgs()
Renders the queued error messages as a list. |
java.lang.String |
getMsgs(java.lang.String property)
Renders the queued error messages of a particual category as a list. |
java.lang.String |
getMsgs(java.lang.String property,
java.lang.String bundle)
Renders the queued error messages of a particual category as a list. |
int |
getSize()
Returns the number of action errors queued. |
int |
getSize(java.lang.String property)
Returns the number of action errors queued for a particular property. |
void |
init(java.lang.Object obj)
Initializes this tool. |
Methods inherited from class org.apache.velocity.tools.struts.MessageResourcesTool |
getResources |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.apache.struts.action.ActionErrors errors
Constructor Detail |
public ErrorsTool()
Method Detail |
public void init(java.lang.Object obj)
init
in interface ViewTool
init
in class MessageResourcesTool
obj
- the current ViewContext
java.lang.IllegalArgumentException
- if the param is not a ViewContextpublic boolean exist()
Returns true
if there are action errors queued,
otherwise false
.
public boolean exist(java.lang.String property)
Returns true if there are action errors queued for the specified
category of errors, otherwise false
.
property
- the category of errors to check forpublic int getSize()
public int getSize(java.lang.String property)
property
- the category of errors to check forpublic java.util.ArrayList getGlobal()
This a convenience method and the equivalent of
$errors.get($errors.globalName)
.
Returns the set of localized error messages as an
java.util.ArrayList
of java.lang.String
for all errors queued of the global category or null
if no error are queued for the specified category.
If the message resources don't contain an error message for a particular error key, the key itself is used as error message.
public java.util.ArrayList getAll()
java.util.ArrayList
of java.lang.String
for all errors queued or null
if no errors are queued.
If the message resources don't contain an error message for a
particular error key, the key itself is used as error message.
public java.util.ArrayList get(java.lang.String property)
java.util.ArrayList
of java.lang.String
for all errors queued of the specified category or null
if no error are queued for the specified category. If the message
resources don't contain an error message for a particular error key,
the key itself is used as error message.
property
- the category of errors to operate onpublic java.util.ArrayList get(java.lang.String property, java.lang.String bundle)
java.util.ArrayList
of java.lang.String
for all errors queued of the specified category or null
if no error are queued for the specified category. If the message
resources don't contain an error message for a particular error key,
the key itself is used as error message.
property
- the category of errors to operate onbundle
- the message resource bundle to usepublic java.lang.String getMsgs()
Renders the queued error messages as a list. This method expects
the message keys errors.header
and errors.footer
in the message resources. The value of the former is rendered before
the list of error messages and the value of the latter is rendered
after the error messages.
public java.lang.String getMsgs(java.lang.String property)
Renders the queued error messages of a particual category as a list.
This method expects the message keys errors.header
and
errors.footer
in the message resources. The value of the
former is rendered before the list of error messages and the value of
the latter is rendered after the error messages.
property
- the category of errors to render
public java.lang.String getMsgs(java.lang.String property, java.lang.String bundle)
Renders the queued error messages of a particual category as a list.
This method expects the message keys errors.header
and
errors.footer
in the message resources. The value of the
former is rendered before the list of error messages and the value of
the latter is rendered after the error messages.
property
- the category of errors to renderbundle
- the message resource bundle to use
public java.lang.String getGlobalName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |