Java Doc for ValidatorTool.java in  » Template-Engine » Velocity » org » apache » velocity » tools » struts » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Template Engine » Velocity » org.apache.velocity.tools.struts 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.velocity.tools.struts.ValidatorTool

ValidatorTool
public class ValidatorTool (Code)

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.


author:
   David Winterfeldt
author:
   David Graham
author:
   Marino A. Jonsson
author:
   Nathan Bubna
since:
   VelocityTools 1.1
version:
   $Revision: 497643 $ $Date: 2007-01-18 15:54:14 -0800 (Thu, 18 Jan 2007) $


Field Summary
protected  ServletContextapp
    
protected  ViewContextcontext
    
protected  StringjsFormName
     formName is used for both Javascript and non-javascript validations.
protected  HttpServletRequestrequest
     A reference to the HttpServletRequest.
protected  ValidatorResourcesresources
     A reference to the ValidatorResources.
protected  HttpSessionsession
     A reference to the HttpSession.

Constructor Summary
public  ValidatorTool()
     Default constructor.

Method Summary
protected  ListcreateActionList(ValidatorResources resources, Form form)
     Get List of actions for the given Form.
protected  StringcreateMethods(List actions)
     Creates the JavaScript methods list from the given actions.
Parameters:
  actions - A List of ValidatorAction objects.
protected  StringescapeJavascript(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.


Parameters:
  str - The string to escape.
public  booleangetCdata()
     Returns the cdata setting "true" or "false".
public  StringgetDynamicJavascript()
     Render just the dynamic JavaScript to perform validations based on the form name attribute of the action mapping associated with the current request (if such exists).
public  StringgetDynamicJavascript(String formName)
     Render just the dynamic JavaScript to perform validations based on the supplied form name.
protected  StringgetDynamicJavascript(ValidatorResources resources, Locale locale, Form form)
     Generates the dynamic JavaScript for the form.
public  booleangetHtmlComment()
     Gets whether or not to delimit the JavaScript with html comments.
public  StringgetJavascript()
     Render both dynamic and static JavaScript to perform validations based on the form name attribute of the action mapping associated with the current request (if such exists).
public  StringgetJavascript(String formName)
     Render both dynamic and static JavaScript to perform validations based on the supplied form name.
protected  StringgetJavascript(String formName, boolean getStatic)
     Render both dynamic and static JavaScript to perform validations based on the supplied form name.
protected  StringgetJavascriptBegin(String methods)
     Returns the opening script element and some initial javascript.
protected  StringgetJavascriptEnd()
     Returns the closing script element.
protected  StringgetJavascriptStaticMethods(ValidatorResources resources)
    
public  StringgetMethod()
     Gets the method name that will be used for the Javascript validation method name if it has a value.
public  intgetPage()
     Gets the current page number of a multi-part form.
public  StringgetSrc()
     Gets the src attribute's value when defining the html script element.
public  StringgetStaticJavascript()
     Render just the static JavaScript methods.
public  voidinit(Object obj)
     Initializes this tool.
public  voidsetCdata(boolean cdata)
     Sets the cdata status.
public  voidsetHtmlComment(boolean htmlComment)
     Sets whether or not to delimit the JavaScript with html comments.
public  voidsetMethod(String methodName)
     Sets the method name that will be used for the Javascript validation method name if it has a value.
public  voidsetPage(int page)
     Sets the current page number of a multi-part form.
public  voidsetSrc(String src)
     Sets the src attribute's value (used to include an external script resource) when defining the html script element.

Field Detail
app
protected ServletContext app(Code)
A reference to the ServletContext



context
protected ViewContext context(Code)
A reference to the ViewContext



jsFormName
protected String jsFormName(Code)
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.



request
protected HttpServletRequest request(Code)
A reference to the HttpServletRequest.



resources
protected ValidatorResources resources(Code)
A reference to the ValidatorResources.



session
protected HttpSession session(Code)
A reference to the HttpSession.




Constructor Detail
ValidatorTool
public ValidatorTool()(Code)
Default constructor. Tool must be initialized before use.




Method Detail
createActionList
protected List createActionList(ValidatorResources resources, Form form)(Code)
Get List of actions for the given Form.
Parameters:
  resources - the validator resources
Parameters:
  form - the form for which the actions are requested A sorted List of ValidatorAction objects.



createMethods
protected String createMethods(List actions)(Code)
Creates the JavaScript methods list from the given actions.
Parameters:
  actions - A List of ValidatorAction objects. JavaScript methods.



escapeJavascript
protected String escapeJavascript(String str)(Code)

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.


Parameters:
  str - The string to escape. The string s with each instance of a double quote,single quote, backslash, carriage-return, or line feed escapedwith a leading backslash.
since:
   VelocityTools 1.2



getCdata
public boolean getCdata()(Code)
Returns the cdata setting "true" or "false". boolean - "true" if JavaScript will be hidden in a CDATA section



getDynamicJavascript
public String getDynamicJavascript() throws Exception(Code)
Render just the dynamic JavaScript to perform validations based on the form name attribute of the action mapping associated with the current request (if such exists). Useful i.e. if the static parts are located in a seperate .js file. the javascript for the current form
throws:
  Exception -



getDynamicJavascript
public String getDynamicJavascript(String formName) throws Exception(Code)
Render just the dynamic JavaScript to perform validations based on the supplied form name. Useful i.e. if the static parts are located in a seperate .js file.
Parameters:
  formName - the key (form name) the dynamic Javascript for the specified form
throws:
  Exception -



getDynamicJavascript
protected String getDynamicJavascript(ValidatorResources resources, Locale locale, Form form)(Code)
Generates the dynamic JavaScript for the form.
Parameters:
  resources - the validator resources
Parameters:
  locale - the locale for the current request
Parameters:
  form - the form to generate javascript for the dynamic javascript



getHtmlComment
public boolean getHtmlComment()(Code)
Gets whether or not to delimit the JavaScript with html comments. If this is set to 'true', which is the default, html comments will surround the JavaScript. true if the JavaScript should be delimited with html comments



getJavascript
public String getJavascript() throws Exception(Code)
Render both dynamic and static JavaScript to perform validations based on the form name attribute of the action mapping associated with the current request (if such exists). the javascript for the current form
throws:
  Exception -



getJavascript
public String getJavascript(String formName) throws Exception(Code)
Render both dynamic and static JavaScript to perform validations based on the supplied form name.
Parameters:
  formName - the key (form name) the Javascript for the specified form
throws:
  Exception -



getJavascript
protected String getJavascript(String formName, boolean getStatic) throws Exception(Code)
Render both dynamic and static JavaScript to perform validations based on the supplied form name.
Parameters:
  formName - the key (form name)
Parameters:
  getStatic - indicates if the static methods should be rendered the Javascript for the specified form
throws:
  Exception -



getJavascriptBegin
protected String getJavascriptBegin(String methods)(Code)
Returns the opening script element and some initial javascript.
Parameters:
  methods - javascript validation methods the opening script element and some initial javascript



getJavascriptEnd
protected String getJavascriptEnd()(Code)
Returns the closing script element. the closing script element



getJavascriptStaticMethods
protected String getJavascriptStaticMethods(ValidatorResources resources)(Code)

Parameters:
  resources - the validation resources the static javascript methods



getMethod
public String getMethod()(Code)
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. the method name that will be used for the Javascript validation method



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



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



getStaticJavascript
public String getStaticJavascript() throws Exception(Code)
Render just the static JavaScript methods. Useful i.e. if the static parts should be located in a seperate .js file. all static Javascript methods
throws:
  Exception -



init
public void init(Object obj)(Code)
Initializes this tool.
Parameters:
  obj - the current ViewContext
throws:
  IllegalArgumentException - if the param is not a ViewContext



setCdata
public void setCdata(boolean cdata)(Code)
Sets the cdata status.
Parameters:
  cdata - The cdata to set



setHtmlComment
public void setHtmlComment(boolean htmlComment)(Code)
Sets whether or not to delimit the JavaScript with html comments. If this is set to 'true', which is the default, html comments will surround the JavaScript.
Parameters:
  htmlComment - whether or not to delimit the JavaScript with html comments



setMethod
public void setMethod(String methodName)(Code)
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.
Parameters:
  methodName - the method name that will be used for the Javascript validation method name



setPage
public void setPage(int page)(Code)
Sets the current page number of a multi-part form. Only field validations with a matching page number will be generated that match the current page number.
Parameters:
  page - the current page number of a multi-part form



setSrc
public void setSrc(String src)(Code)
Sets the src attribute's value (used to include an external script resource) when defining the html script element. The src attribute is only recognized when the formName attribute is specified.
Parameters:
  src - the src attribute's value



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.