Java Doc for LazyValidatorForm.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » validator » 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 » Web Framework » struts 1.3.8 » org.apache.struts.validator 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.struts.validator.ValidatorForm
   org.apache.struts.validator.BeanValidatorForm
      org.apache.struts.validator.LazyValidatorForm

LazyValidatorForm
public class LazyValidatorForm extends BeanValidatorForm (Code)

Struts Lazy ActionForm which wraps a LazyDynaBean.

There isn't really that much to this implementation as most of the lazy behaviour is in LazyDynaBean and wrapping the LazyDynaBean is handled in the parent BeanValidatorForm. The only thing it really does is populate indexed properties which are a List type with a LazyDynaBean in the get(name, index) method.

Lazy DynaBeans provide several types of lazy behaviour:

  • lazy property addition - properties which do not exist are automatically added.
  • lazy List facilities - automatically grows a List or Array to accomodate the index value being set.
  • lazy List creation - automatic creation of a List or Array for indexed properties, if it doesn't exist.
  • lazy Map creation - automatic creation of a Map for mapped properties, if it doesn't exist.

Using this lazy ActionForm means that you don't have to define the ActionForm's properties in the struts-config.xml. However, a word of warning, everything in the Request gets populated into this ActionForm circumventing the normal firewall function of Struts forms. Therefore you should only take out of this form properties you expect to be there rather than blindly populating all the properties into the business tier.

Having said that it is not necessary to pre-define properties in the struts-config.xml, it is useful to sometimes do so for mapped or indexed properties. For example, if you want to use a different Map implementation from the default HashMap or an array for indexed properties, rather than the default List type:


 <form-bean name="myForm" type="org.apache.struts.validator.LazyValidatorForm">
 <form-property name="myMap" type="java.util.TreeMap" />
 <form-property name="myBeans" type="org.apache.commons.beanutils.LazyDynaBean[]"
 />
 </form-bean>
 

Another reason for defining indexed properties in the struts-config.xml is that if you are validating indexed properties using the Validator and none are submitted then the indexed property will be null which causes validator to fail. Pre-defining them in the struts-config.xml will result in a zero-length indexed property (array or List) being instantiated, avoiding an issue with validator in that circumstance.

This implementation validates using the ActionForm name. If you require a version that validates according to the path then it can be easily created in the following manner:


 public class MyLazyForm extends LazyValidatorForm {
 public MyLazyForm () {
 super();
 setPathValidation(true);
 }
 }
 

Rather than using this class, another alternative is to either use a LazyDynaBean or custom version of LazyDynaBean directly. Struts now automatically wraps objects which are not ActionForms in a BeanValidatorForm. For example:


 <form-bean name="myForm" type="org.apache.commons.beanutils.LazyDynaBean">
 <form-property name="myBeans" type="org.apache.commons.beanutils.LazyDynaBean[]"
 />
 </form-bean>
 

version:
   $Rev: 471754 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
version:
   $
See Also:    Commons * BeanUtils JavaDoc
since:
   Struts 1.2.6



Constructor Summary
public  LazyValidatorForm()
     Default Constructor which creates a LazyDynaBean to back this form.
public  LazyValidatorForm(DynaBean bean)
    

Method Summary
public  Objectget(String name, int index)
    
public  MapgetMap()
    
protected  DynaBeannewIndexedBean(String name)
    


Constructor Detail
LazyValidatorForm
public LazyValidatorForm()(Code)
Default Constructor which creates a LazyDynaBean to back this form.



LazyValidatorForm
public LazyValidatorForm(DynaBean bean)(Code)




Method Detail
get
public Object get(String name, int index)(Code)

Return an indexed property value.

If the "indexed" property is a List type then any missing values are populated with a bean (created in the newIndexedBean(name) method - in this implementation this is a LazyDynaBean type.




getMap
public Map getMap()(Code)

Return the Map containing the property values.

Provided so that properties can be access using JSTL.




newIndexedBean
protected DynaBean newIndexedBean(String name)(Code)

Creates new DynaBean instances to populate an 'indexed' property of beans - defaults to LazyDynaBean type.

Override this method if you require a different type of DynaBean.




Fields inherited from org.apache.struts.validator.BeanValidatorForm
protected DynaBean dynaBean(Code)(Java Doc)
protected static Log logger(Code)(Java Doc)
protected boolean pathValidation(Code)(Java Doc)

Methods inherited from org.apache.struts.validator.BeanValidatorForm
public boolean contains(String name, String key)(Code)(Java Doc)
public Object get(String name)(Code)(Java Doc)
public Object get(String name, int index)(Code)(Java Doc)
public Object get(String name, String key)(Code)(Java Doc)
public DynaBean getDynaBean()(Code)(Java Doc)
public DynaClass getDynaClass()(Code)(Java Doc)
public Object getInstance()(Code)(Java Doc)
public String getStrutsConfigFormName()(Code)(Java Doc)
public String getValidationKey(ActionMapping mapping, HttpServletRequest request)(Code)(Java Doc)
public void initialize(FormBeanConfig formBeanConfig)(Code)(Java Doc)
protected boolean isPathValidation()(Code)(Java Doc)
public void remove(String name, String key)(Code)(Java Doc)
public void set(String name, Object value)(Code)(Java Doc)
public void set(String name, int index, Object value)(Code)(Java Doc)
public void set(String name, String key, Object value)(Code)(Java Doc)
protected void setPathValidation(boolean pathValidation)(Code)(Java Doc)
public int size(String name)(Code)(Java Doc)

Fields inherited from org.apache.struts.validator.ValidatorForm
protected int page(Code)(Java Doc)
protected ValidatorResults validatorResults(Code)(Java Doc)

Methods inherited from org.apache.struts.validator.ValidatorForm
public int getPage()(Code)(Java Doc)
public Map getResultValueMap()(Code)(Java Doc)
public String getValidationKey(ActionMapping mapping, HttpServletRequest request)(Code)(Java Doc)
public ValidatorResults getValidatorResults()(Code)(Java Doc)
public void reset(ActionMapping mapping, HttpServletRequest request)(Code)(Java Doc)
public void setPage(int page)(Code)(Java Doc)
public void setValidatorResults(ValidatorResults validatorResults)(Code)(Java Doc)
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)(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.