|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.jsp.tagext.TagSupport | +--javax.servlet.jsp.tagext.BodyTagSupport | +--org.apache.struts.taglib.html.JavascriptValidatorTag
Custom tag that generates JavaScript for client side validation based
on the validation rules loaded by the ValidatorPlugIn
defined in the struts-config.xml file.
Field Summary | |
private static java.util.Comparator |
actionComparator
A Comparator to use when sorting ValidatorAction objects. |
protected java.lang.String |
bundle
The servlet context attribute key for our resources. |
protected java.lang.String |
cdata
Hide JavaScript methods in a CDATA section for XHTML when "true". |
protected static java.util.Locale |
defaultLocale
Deprecated. This variable is no longer used. |
protected java.lang.String |
dynamicJavascript
The dynamic JavaScript objects will only be generated if this is set to "true". |
protected java.lang.String |
formName
The name of the form that corresponds with the action name in struts-config.xml. |
protected static java.lang.String |
HTML_BEGIN_COMMENT
The start of the HTML comment hiding JavaScript from old browsers. |
protected static java.lang.String |
HTML_END_COMMENT
The end of the HTML comment hiding JavaScript from old browsers. |
protected java.lang.String |
htmlComment
The JavaScript methods will enclosed with html comments if this is set to "true". |
protected java.lang.String |
jsFormName
formName is used for both Javascript and non-javascript validations. |
protected static java.lang.String |
lineEnd
The line ending string. |
protected java.lang.String |
methodName
This will be used as is for the JavaScript validation method name if it has a value. |
protected int |
page
The current page number of a multi-part form. |
protected boolean |
scriptLanguage
Include language attribute in the <script> element. |
protected java.lang.String |
src
The src attribute for html script element (used to include an external script resource). |
protected java.lang.String |
staticJavascript
The static JavaScript methods will only be printed if this is set to "true". |
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
bodyContent |
Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
id, pageContext, parent, values |
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
EVAL_BODY_TAG |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
JavascriptValidatorTag()
|
Method Summary | |
private java.util.List |
createActionList(org.apache.commons.validator.ValidatorResources resources,
org.apache.commons.validator.Form form)
Get List of actions for the given Form. |
private java.lang.String |
createDynamicJavascript(ModuleConfig config,
org.apache.commons.validator.ValidatorResources resources,
java.util.Locale locale,
org.apache.commons.validator.Form form)
Generates the dynamic JavaScript for the form. |
private java.lang.String |
createMethods(java.util.List actions,
boolean stopOnError)
Creates the JavaScript methods list from the given actions. |
int |
doStartTag()
Render the JavaScript for to perform validations based on the form name. |
private java.lang.String |
escapeJavascript(java.lang.String str)
Backslash-escapes the following characters from the input string: ", ', \, \r, \n. |
private java.lang.String |
escapeQuotes(java.lang.String in)
|
java.lang.String |
getBundle()
Sets the servlet context attribute key for our resources. |
java.lang.String |
getCdata()
Returns the cdata setting "true" or "false". |
java.lang.String |
getDynamicJavascript()
Gets whether or not to generate the dynamic JavaScript. |
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. |
java.lang.String |
getHtmlComment()
Gets whether or not to delimit the JavaScript with html comments. |
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 |
getJsFormName()
|
java.lang.String |
getMethod()
Gets the method name that will be used for the Javascript validation method name if it has a value. |
int |
getPage()
Gets the current page number of a multi-part form. |
boolean |
getScriptLanguage()
Gets whether or not the <script> element will include the language attribute. |
java.lang.String |
getSrc()
Gets the src attribute's value when defining the html script element. |
java.lang.String |
getStaticJavascript()
Gets whether or not to generate the static JavaScript. |
private boolean |
isXhtml()
Returns true if this is an xhtml page. |
void |
release()
Release any acquired resources. |
protected java.lang.String |
renderJavascript()
Returns fully rendered JavaScript. |
protected java.lang.String |
renderStartElement()
Constructs the beginning <script> element depending on XHTML status. |
void |
setBundle(java.lang.String bundle)
Gets the servlet context attribute key for our resources. |
void |
setCdata(java.lang.String cdata)
Sets the cdata status. |
void |
setDynamicJavascript(java.lang.String dynamicJavascript)
Sets whether or not to generate the dynamic JavaScript. |
void |
setFormName(java.lang.String formName)
Sets 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. |
void |
setHtmlComment(java.lang.String htmlComment)
Sets whether or not to delimit the JavaScript with html comments. |
void |
setJsFormName(java.lang.String jsFormName)
|
void |
setMethod(java.lang.String methodName)
Sets the method name that will be used for the Javascript validation method name if it has a value. |
void |
setPage(int page)
Sets the current page number of a multi-part form. |
void |
setScriptLanguage(boolean scriptLanguage)
Sets whether or not the <script> element will include the language attribute. |
void |
setSrc(java.lang.String src)
Sets the src attribute's value when defining the html script element. |
void |
setStaticJavascript(java.lang.String staticJavascript)
Sets whether or not to generate the static JavaScript. |
private boolean |
stopOnError(ModuleConfig config)
Determines if validations should stop on an error. |
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
doAfterBody, doEndTag, doInitBody, getBodyContent, getPreviousOut, setBodyContent |
Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue |
Methods inherited from class java.lang.Object |
|
Methods inherited from interface javax.servlet.jsp.tagext.Tag |
getParent, setPageContext, setParent |
Field Detail |
private static final java.util.Comparator actionComparator
protected static final java.lang.String HTML_BEGIN_COMMENT
protected static final java.lang.String HTML_END_COMMENT
protected java.lang.String bundle
protected static java.util.Locale defaultLocale
protected java.lang.String formName
protected java.lang.String jsFormName
protected static java.lang.String lineEnd
protected int page
protected java.lang.String methodName
protected boolean scriptLanguage
protected java.lang.String staticJavascript
protected java.lang.String dynamicJavascript
protected java.lang.String src
protected java.lang.String htmlComment
protected java.lang.String cdata
Constructor Detail |
public JavascriptValidatorTag()
Method Detail |
public java.lang.String getFormName()
public void setFormName(java.lang.String formName)
public java.lang.String getJsFormName()
public void setJsFormName(java.lang.String jsFormName)
jsFormName
- The jsFormName to set.public int getPage()
public void setPage(int page)
public java.lang.String getMethod()
public void setMethod(java.lang.String methodName)
public java.lang.String getStaticJavascript()
public void setStaticJavascript(java.lang.String staticJavascript)
public java.lang.String getDynamicJavascript()
public void setDynamicJavascript(java.lang.String dynamicJavascript)
public java.lang.String getHtmlComment()
public void setHtmlComment(java.lang.String htmlComment)
public java.lang.String getSrc()
public void setSrc(java.lang.String src)
public java.lang.String getBundle()
public void setBundle(java.lang.String bundle)
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
- if a JSP exception has occurredprotected java.lang.String renderJavascript() throws javax.servlet.jsp.JspException
private java.lang.String createDynamicJavascript(ModuleConfig config, org.apache.commons.validator.ValidatorResources resources, java.util.Locale locale, org.apache.commons.validator.Form form) throws javax.servlet.jsp.JspException
config
- resources
- locale
- form
- private java.lang.String escapeQuotes(java.lang.String in)
private java.lang.String escapeJavascript(java.lang.String str)
Backslash-escapes the following characters from the input string: ", ', \, \r, \n.
This method escapes characters that will result in an invalid Javascript statement within the validator Javascript.
str
- The string to escape.s
with each instance of a double quote,
single quote, backslash, carriage-return, or line feed escaped
with a leading backslash.private boolean stopOnError(ModuleConfig config)
config
- The ModuleConfig
used to lookup the
stopOnError setting.true
if validations should stop on errors.private java.lang.String createMethods(java.util.List actions, boolean stopOnError)
actions
- A List of ValidatorAction objects.stopOnError
- If true, behaves like released version of struts 1.1
and stops after first error. If false, evaluates all validations.private java.util.List createActionList(org.apache.commons.validator.ValidatorResources resources, org.apache.commons.validator.Form form)
resources
- form
- public void release()
release
in class javax.servlet.jsp.tagext.BodyTagSupport
protected java.lang.String getJavascriptBegin(java.lang.String methods)
protected java.lang.String getJavascriptStaticMethods(org.apache.commons.validator.ValidatorResources resources)
protected java.lang.String getJavascriptEnd()
protected java.lang.String renderStartElement()
private boolean isXhtml()
public java.lang.String getCdata()
public void setCdata(java.lang.String cdata)
cdata
- The cdata to setpublic boolean getScriptLanguage()
public void setScriptLanguage(boolean scriptLanguage)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |