|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.tools.struts.ErrorsTool
View tool to work with the Struts error messages.
This class is equipped to be used with a toolbox manager, for example the ServletToolboxManager included with VelServlet. This class implements interface ViewTool, which allows a toolbox manager to pass the required context information.
This class is not thread-safe by design. A new instance is needed for the processing of every template request. This means this tool should only be used in the request scope, not application or session scopes.
Field Summary | |
protected javax.servlet.ServletContext |
application
A reference to the ServletContext |
protected org.apache.struts.action.ActionErrors |
errors
A reference to the queued action messages. |
protected java.util.Locale |
locale
A reference to the user's locale. |
protected javax.servlet.http.HttpServletRequest |
request
A reference to the HttpServletRequest. |
protected org.apache.struts.util.MessageResources |
resources
A reference to the Struts message resources. |
protected javax.servlet.http.HttpSession |
session
A reference to the HttpSession. |
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 |
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. |
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected javax.servlet.ServletContext application
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpSession session
protected org.apache.struts.util.MessageResources resources
protected java.util.Locale locale
protected org.apache.struts.action.ActionErrors errors
Constructor Detail |
public ErrorsTool()
Method Detail |
public void init(java.lang.Object obj)
init
in interface ViewTool
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.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 getGlobalName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |