org.apache.struts.taglib.html
クラス JavascriptValidatorTag

java.lang.Object
  拡張javax.servlet.jsp.tagext.TagSupport
      拡張javax.servlet.jsp.tagext.BodyTagSupport
          拡張org.apache.struts.taglib.html.JavascriptValidatorTag
すべての実装インタフェース:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class JavascriptValidatorTag
extends javax.servlet.jsp.tagext.BodyTagSupport

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.

導入されたバージョン:
Struts 1.1
バージョン:
$Revision: 1.1 $ $Date: 2004/10/20 03:26:42 $
関連項目:
直列化された形式

フィールドの概要
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
          推奨されていません。 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".
 
クラス javax.servlet.jsp.tagext.BodyTagSupport から継承したフィールド
bodyContent
 
クラス javax.servlet.jsp.tagext.TagSupport から継承したフィールド
id, pageContext
 
インタフェース javax.servlet.jsp.tagext.BodyTag から継承したフィールド
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
インタフェース javax.servlet.jsp.tagext.IterationTag から継承したフィールド
EVAL_BODY_AGAIN
 
インタフェース javax.servlet.jsp.tagext.Tag から継承したフィールド
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
コンストラクタの概要
JavascriptValidatorTag()
           
 
メソッドの概要
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 escapeQuotes(java.lang.String in)
           
 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 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.
 
クラス javax.servlet.jsp.tagext.BodyTagSupport から継承したメソッド
doAfterBody, doEndTag, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
クラス javax.servlet.jsp.tagext.TagSupport から継承したメソッド
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
インタフェース javax.servlet.jsp.tagext.BodyTag から継承したメソッド
 
インタフェース javax.servlet.jsp.tagext.Tag から継承したメソッド
getParent, setPageContext, setParent
 

フィールドの詳細

actionComparator

private static final java.util.Comparator actionComparator
A Comparator to use when sorting ValidatorAction objects.


HTML_BEGIN_COMMENT

protected static final java.lang.String HTML_BEGIN_COMMENT
The start of the HTML comment hiding JavaScript from old browsers.

導入されたバージョン:
Struts 1.2
関連項目:
定数フィールド値

HTML_END_COMMENT

protected static final java.lang.String HTML_END_COMMENT
The end of the HTML comment hiding JavaScript from old browsers.

導入されたバージョン:
Struts 1.2
関連項目:
定数フィールド値

bundle

protected java.lang.String bundle
The servlet context attribute key for our resources.


defaultLocale

protected static java.util.Locale defaultLocale
推奨されていません。 This variable is no longer used.

The default locale on our server.


formName

protected java.lang.String formName
The name of the form that corresponds with the action name in struts-config.xml. Specifying a form name places a <script> </script> around the javascript.


jsFormName

protected java.lang.String jsFormName
formName is used for both Javascript and non-javascript validations. For the javascript validations, there is the possibility that we will be rewriting the formName (if it is a ValidatorActionForm instead of just a ValidatorForm) so we need another variable to hold the formName just for javascript usage.


lineEnd

protected static java.lang.String lineEnd
The line ending string.


page

protected int page
The current page number of a multi-part form. Only valid when the formName attribute is set.


methodName

protected java.lang.String methodName
This will be used as is for the JavaScript validation method name if it has a value. This is the method name of the main JavaScript method that the form calls to perform validations.


scriptLanguage

protected boolean scriptLanguage
Include language attribute in the <script> element. This property is ignored in XHTML mode.

導入されたバージョン:
Struts 1.2

staticJavascript

protected java.lang.String staticJavascript
The static JavaScript methods will only be printed if this is set to "true".


dynamicJavascript

protected java.lang.String dynamicJavascript
The dynamic JavaScript objects will only be generated if this is set to "true".


src

protected java.lang.String src
The src attribute for html script element (used to include an external script resource). The src attribute is only recognized when the formName attribute is specified.


htmlComment

protected java.lang.String htmlComment
The JavaScript methods will enclosed with html comments if this is set to "true".


cdata

protected java.lang.String cdata
Hide JavaScript methods in a CDATA section for XHTML when "true".

コンストラクタの詳細

JavascriptValidatorTag

public JavascriptValidatorTag()
メソッドの詳細

getFormName

public 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.


setFormName

public 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. Specifying a form name places a <script> </script> tag around the javascript.


getJsFormName

public java.lang.String getJsFormName()
戻り値:
Returns the jsFormName.

setJsFormName

public void setJsFormName(java.lang.String jsFormName)
パラメータ:
jsFormName - The jsFormName to set.

getPage

public int getPage()
Gets the current page number of a multi-part form. Only field validations with a matching page numer will be generated that match the current page number. Only valid when the formName attribute is set.


setPage

public void setPage(int page)
Sets the current page number of a multi-part form. Only field validations with a matching page numer will be generated that match the current page number. Only valid when the formName attribute is set.


getMethod

public java.lang.String getMethod()
Gets the method name that will be used for the Javascript validation method name if it has a value. This overrides the auto-generated method name based on the key (form name) passed in.


setMethod

public 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. This overrides the auto-generated method name based on the key (form name) passed in.


getStaticJavascript

public java.lang.String getStaticJavascript()
Gets whether or not to generate the static JavaScript. If this is set to 'true', which is the default, the static JavaScript will be generated.


setStaticJavascript

public void setStaticJavascript(java.lang.String staticJavascript)
Sets whether or not to generate the static JavaScript. If this is set to 'true', which is the default, the static JavaScript will be generated.


getDynamicJavascript

public java.lang.String getDynamicJavascript()
Gets whether or not to generate the dynamic JavaScript. If this is set to 'true', which is the default, the dynamic JavaScript will be generated.


setDynamicJavascript

public void setDynamicJavascript(java.lang.String dynamicJavascript)
Sets whether or not to generate the dynamic JavaScript. If this is set to 'true', which is the default, the dynamic JavaScript will be generated.


getHtmlComment

public java.lang.String getHtmlComment()
Gets whether or not to delimit the JavaScript with html comments. If this is set to 'true', which is the default, the htmlComment will be surround the JavaScript.


setHtmlComment

public void setHtmlComment(java.lang.String htmlComment)
Sets whether or not to delimit the JavaScript with html comments. If this is set to 'true', which is the default, the htmlComment will be surround the JavaScript.


getSrc

public java.lang.String getSrc()
Gets the src attribute's value when defining the html script element.


setSrc

public void setSrc(java.lang.String src)
Sets the src attribute's value when defining the html script element. The src attribute is only recognized when the formName attribute is specified.


doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Render the JavaScript for to perform validations based on the form name.

例外:
javax.servlet.jsp.JspException - if a JSP exception has occurred

renderJavascript

protected java.lang.String renderJavascript()
                                     throws javax.servlet.jsp.JspException
Returns fully rendered JavaScript.

例外:
javax.servlet.jsp.JspException
導入されたバージョン:
Struts 1.2

createDynamicJavascript

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
Generates the dynamic JavaScript for the form.

パラメータ:
config -
resources -
locale -
form -
例外:
javax.servlet.jsp.JspException

escapeQuotes

private java.lang.String escapeQuotes(java.lang.String in)

stopOnError

private boolean stopOnError(ModuleConfig config)
Determines if validations should stop on an error.

パラメータ:
config - The ModuleConfig used to lookup the stopOnError setting.
戻り値:
true if validations should stop on errors.

createMethods

private java.lang.String createMethods(java.util.List actions,
                                       boolean stopOnError)
Creates the JavaScript methods list from the given actions.

パラメータ:
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.
戻り値:
JavaScript methods.

createActionList

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.

パラメータ:
resources -
form -
戻り値:
A sorted List of ValidatorAction objects.

release

public void release()
Release any acquired resources.


getJavascriptBegin

protected java.lang.String getJavascriptBegin(java.lang.String methods)
Returns the opening script element and some initial javascript.


getJavascriptStaticMethods

protected java.lang.String getJavascriptStaticMethods(org.apache.commons.validator.ValidatorResources resources)

getJavascriptEnd

protected java.lang.String getJavascriptEnd()
Returns the closing script element.


renderStartElement

protected java.lang.String renderStartElement()
Constructs the beginning <script> element depending on XHTML status.

導入されたバージョン:
Struts 1.2

isXhtml

private boolean isXhtml()
Returns true if this is an xhtml page.


getCdata

public java.lang.String getCdata()
Returns the cdata setting "true" or "false".

戻り値:
String - "true" if JavaScript will be hidden in a CDATA section

setCdata

public void setCdata(java.lang.String cdata)
Sets the cdata status.

パラメータ:
cdata - The cdata to set

getScriptLanguage

public boolean getScriptLanguage()
Gets whether or not the <script> element will include the language attribute.

戻り値:
true if language attribute will be included.
導入されたバージョン:
Struts 1.2

setScriptLanguage

public void setScriptLanguage(boolean scriptLanguage)
Sets whether or not the <script> element will include the language attribute.

導入されたバージョン:
Struts 1.2


このドキュメントは、Ja-Jakartaにより訳されました。コメントがある場合は、report@jajakarta.orgまでお願いします。
Copyright (C) 2000-2004 - Apache Software Foundation