|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.velocity.tools.struts.ValidatorTool
View tool that works with Struts Validator to produce client side javascript validation for your forms.
Usage:
Template example: $validator.getJavascript("nameOfYourForm") Toolbox configuration: <tool> <key>validator</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.ValidatorTool</class> </tool>
This is an adaptation of the JavascriptValidatorTag from the Struts 1.1 validator library.
Nested Class Summary | |
protected class |
ValidatorTool.ValidatorActionComparator
Inner class for use when creating dynamic javascript |
Field Summary | |
protected javax.servlet.ServletContext |
app
A reference to the ServletContext |
private boolean |
cdata
|
protected ViewContext |
context
A reference to the ViewContext |
private boolean |
dynamicJavascript
|
private java.lang.String |
formName
|
private static java.lang.String |
HTML_BEGIN_COMMENT
|
private static java.lang.String |
HTML_END_COMMENT
|
private boolean |
htmlComment
|
private java.lang.String |
methodName
|
private int |
page
|
protected javax.servlet.http.HttpServletRequest |
request
A reference to the HttpServletRequest. |
protected javax.servlet.http.HttpSession |
session
A reference to the HttpSession. |
private java.lang.String |
src
|
private boolean |
staticJavascript
|
private boolean |
xhtml
|
Constructor Summary | |
ValidatorTool()
Default constructor. |
Method Summary | |
protected java.util.List |
createActionList(org.apache.commons.validator.ValidatorResources resources,
org.apache.commons.validator.Form form)
Get List of actions for the given Form. |
protected java.lang.String |
createMethods(java.util.List actions)
Creates the JavaScript methods list from the given actions. |
boolean |
getCdata()
Returns the cdata setting "true" or "false". |
boolean |
getDynamicJavascript()
Gets whether or not to generate the dynamic JavaScript. |
protected java.lang.String |
getDynamicJavascript(org.apache.commons.validator.ValidatorResources resources,
java.util.Locale locale,
org.apache.commons.validator.Form form)
Generates the dynamic JavaScript for the form. |
java.lang.String |
getFormName()
Gets the key (form name) that will be used to retrieve a set of validation rules to be performed on the bean passed in for validation. |
boolean |
getHtmlComment()
Gets whether or not to delimit the JavaScript with html comments. |
java.lang.String |
getJavascript()
Render the JavaScript for to perform validations based on the form name already set the form name via setFormName(java.lang.String)
or the form name attribute of the action mapping associated
with the current request (if such exists). |
java.lang.String |
getJavascript(java.lang.String formName)
Render the JavaScript for to perform validations based on the form name. |
protected java.lang.String |
getJavascriptBegin(java.lang.String methods)
Returns the opening script element and some initial javascript. |
protected java.lang.String |
getJavascriptEnd()
Returns the closing script element. |
protected java.lang.String |
getJavascriptStaticMethods(org.apache.commons.validator.ValidatorResources resources)
|
java.lang.String |
getMethod()
Gets the method name that will be used for the Javascript validation method name if it has a value. |
private java.lang.String |
getNextVar(java.lang.String input)
The value null will be returned at the end of the sequence. |
int |
getPage()
Gets the current page number of a multi-part form. |
java.lang.String |
getSrc()
Gets the src attribute's value when defining the html script element. |
private java.lang.String |
getStartElement()
Constructs the beginning tag around the javascript.
getPagepublic int getPage()
setPagepublic void setPage(int page)
getMethodpublic java.lang.String getMethod()
setMethodpublic void setMethod(java.lang.String methodName)
getStaticJavascriptpublic boolean getStaticJavascript()
setStaticJavascriptpublic void setStaticJavascript(boolean staticJavascript)
getDynamicJavascriptpublic boolean getDynamicJavascript()
setDynamicJavascriptpublic void setDynamicJavascript(boolean dynamicJavascript)
getHtmlCommentpublic boolean getHtmlComment()
setHtmlCommentpublic void setHtmlComment(boolean htmlComment)
getSrcpublic java.lang.String getSrc()
setSrcpublic void setSrc(java.lang.String src)
getCdatapublic boolean getCdata()
setCdatapublic void setCdata(boolean cdata)
getJavascriptpublic java.lang.String getJavascript() throws java.lang.Exception
getJavascriptpublic java.lang.String getJavascript(java.lang.String formName) throws java.lang.Exception
getDynamicJavascriptprotected java.lang.String getDynamicJavascript(org.apache.commons.validator.ValidatorResources resources, java.util.Locale locale, org.apache.commons.validator.Form form)
createMethodsprotected java.lang.String createMethods(java.util.List actions)
createActionListprotected java.util.List createActionList(org.apache.commons.validator.ValidatorResources resources, org.apache.commons.validator.Form form)
getJavascriptBeginprotected java.lang.String getJavascriptBegin(java.lang.String methods)
getJavascriptStaticMethodsprotected java.lang.String getJavascriptStaticMethods(org.apache.commons.validator.ValidatorResources resources)
getJavascriptEndprotected java.lang.String getJavascriptEnd()
getNextVarprivate java.lang.String getNextVar(java.lang.String input)
replaceCharprivate java.lang.String replaceChar(java.lang.String input, int pos, char c)
getStartElementprivate java.lang.String getStartElement()
|
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |