Java Doc for WField.java in  » Database-ORM » SimpleORM » simpleorm » simplewebapp » core » 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 » Database ORM » SimpleORM » simpleorm.simplewebapp.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   simpleorm.simplewebapp.core.WFieldNode
      simpleorm.simplewebapp.core.WField

All known Subclasses:   simpleorm.simplewebapp.scalarFields.WFieldDate,  simpleorm.simplewebapp.scalarFields.WFieldImage,  simpleorm.simplewebapp.scalarFields.WFieldLong,  simpleorm.simplewebapp.scalarFields.WFieldString,  simpleorm.simplewebapp.scalarFields.WFieldBoolean,  simpleorm.simplewebapp.scalarFields.WFieldInteger,
WField
abstract public class WField extends WFieldNode (Code)
The data field properties. Each instance represents one crud or list field in a form. Subtypes implement different data types and validation, eg. WFieldString.

This class stores the rawText entered by the user (normally via the HttpRequest.parameter).

When this is Validated it is Parsed to produce a typed value. If the parse fails then the rawText value is retained so that the user can edit it and re-submit the form.

Note that if it does parse, then this.text is nulled, so that this.value is the source of truth.

getText returns either the non-null thus non-validated text, or a formatted version of getValue.

It is tempting to split out the different widgets (vs data type) into a separate delegated hierarchy. But that is not necessary, the jstl .tags render them and the few special properties required do NOT warant that complexity. Just merge per widget properties in WField, maybe add a Properties later.

It is also tempting to split out the data source into a separate heirarchy, so that tight integration with an ORM can be achieved. However, that again is unnecessary as it is far better to achieve the integration with a simple generate approach rather than direct references involving complex inheritance rules.

It took quite a while to get this class simple!



Field Summary
final public static  StringCHECKBOX
    
final public static  StringFILE
    
final public static  StringHIDDEN
    
final public static  StringIMAGE
    
final public static  StringPASSWORD
    
final public static  StringRADIO
    
final public static  StringRADIO_VERTICAL
    
final public static  StringSELECT
    
final public static  StringTEXT
    
 StringanchorHRef
     If non-null, wrap the (list) field with an anchor with HRef= this.
 ObjectdataField
     Reference to a field in an external ORM etc.
 StringdataName
     Used by auto List to access the columns/data field, defaults to name.
 intdisplayLength
     Default display length, in chars, mainly for input boxes.
 ObjectextraProperties
     Arbitrary extra properties Not used directly by SimpleWebApp.
 WFieldGroupgroup
    
 intmaxLength
     Enforced max length of the raw text, in 16 bit UTF char lengths.
 booleannotRetrieved
     Can be set to indicate that a parameter should not be retrieved by WPage.retrieveParameters.
 Listoptions
     For Select/Option, radio buttons etc.
protected  StringrawText
     The raw value retrieved from HtmlRequest.
 booleanreadOnly
     Cannot be changed by the end user.
 booleanrequired
    
protected  Objectvalue
     The parsed and processed value, eg.
 Stringwidget
     The type of widget/control.

Constructor Summary
public  WField(String shortName)
    
public  WField(String shortName, String widget)
    

Method Summary
 voidcheckRequired()
    
abstract protected  Stringformat()
     Convert the value to a string.

The is called by getText to set the INPUT value= etc.

public  StringgetAnchorHRef()
    
public  booleangetBooleanValue(boolean defalt)
     Interpret the field as a boolean, mainly for checkbox widgets. Implemented for Strings, Integers etc.
public  booleangetBooleanValue()
    
public  ObjectgetDataField()
    
public  StringgetDataName()
     Name used to idenify the column in a data source.
public  intgetDisplayLength()
    
public  ObjectgetExtraProperties()
    
public  intgetMaxLength()
    
public  ListgetOptions()
    
public  StringgetText()
     Return the text representation of this field.
public  ObjectgetValue()
     Just casts value to correct type. Nulls returned as nulls, including booleans.
public  TgetValue(T defalt)
    
abstract public  ClassgetValueClass()
     Returns the class for which the value must be a subclass.

Also used to find the set*() method of the bean by WBeanUtils.

public  StringgetWidget()
     The widget, eg radiobutton, text, select...
public  booleanisNotRetrieved()
    
public  booleanisReadOnly()
    
public  booleanisRequired()
    
protected  voidonValidateAlways()
     Always called regardless of whether form wasSubmitted() or value is null.
protected  voidonValidateNotNull()
     Override this method to add extra validation. Called after required and data checks but before all other fields have been validated.
abstract protected  voidparse(String rawText)
     Parse text and store it as the value.
public  voidsetAnchorHRef(String anchorHRef)
    
public  WFieldsetDataField(Object dataField)
    
public  WFieldsetDataName(String dataName)
    
public  FsetDisplayLength(int displayLength)
    
public  WFieldsetExtraProperties(Object extraProperties)
    
public  FsetMaxLength(int maxLength)
    
public  WFieldsetNotRetrieved(boolean notRetrieved)
    
public  voidsetOptions(List options)
    
public  WFieldsetPostedText(String text)
     Sets the initial value of the raw text field, typically directly from a HttpRequest.parameter.

Called by the framework or test cases between doInitialize and doProcess, the latter which then parses it to a getValue.

Also trims spaces and converts "" to null.

public  FsetReadOnly(boolean readOnly)
    
public  FsetRequired(boolean required)
    
public  WFieldsetValue(Object value)
     Set the value, must be the correct type, eg.
public  voidsetWidget(String widget)
    
public  StringtoString()
    
 voidvalidateField()
     Called by doProcess to validates the field and parses it into the value.

Field Detail
CHECKBOX
final public static String CHECKBOX(Code)



FILE
final public static String FILE(Code)



HIDDEN
final public static String HIDDEN(Code)



IMAGE
final public static String IMAGE(Code)



PASSWORD
final public static String PASSWORD(Code)



RADIO
final public static String RADIO(Code)



RADIO_VERTICAL
final public static String RADIO_VERTICAL(Code)



SELECT
final public static String SELECT(Code)



TEXT
final public static String TEXT(Code)



anchorHRef
String anchorHRef(Code)
If non-null, wrap the (list) field with an anchor with HRef= this.



dataField
Object dataField(Code)
Reference to a field in an external ORM etc. Not directly used by SimpleWebApp.



dataName
String dataName(Code)
Used by auto List to access the columns/data field, defaults to name. todo this usage conflicts with dataField, only one of these should be used.



displayLength
int displayLength(Code)
Default display length, in chars, mainly for input boxes.



extraProperties
Object extraProperties(Code)
Arbitrary extra properties Not used directly by SimpleWebApp.



group
WFieldGroup group(Code)



maxLength
int maxLength(Code)
Enforced max length of the raw text, in 16 bit UTF char lengths. -1 means no limit.



notRetrieved
boolean notRetrieved(Code)
Can be set to indicate that a parameter should not be retrieved by WPage.retrieveParameters.



options
List options(Code)
For Select/Option, radio buttons etc.



rawText
protected String rawText(Code)
The raw value retrieved from HtmlRequest. This is what is referenced by the .jsps. See class docs.



readOnly
boolean readOnly(Code)
Cannot be changed by the end user. Normally rendered as a Hidden <Input> with the actual value shown in a <span> Mainly for database keys.



required
boolean required(Code)
End user must not leave the field null *



value
protected Object value(Code)
The parsed and processed value, eg. an Integer. Used by code, but Not used by the .jsps, see class docs.



widget
String widget(Code)
The type of widget/control.




Constructor Detail
WField
public WField(String shortName)(Code)



WField
public WField(String shortName, String widget)(Code)




Method Detail
checkRequired
void checkRequired()(Code)



format
abstract protected String format()(Code)
Convert the value to a string.

The is called by getText to set the INPUT value= etc. so it should return a value that can be parsed in a subsequent post.




getAnchorHRef
public String getAnchorHRef()(Code)



getBooleanValue
public boolean getBooleanValue(boolean defalt)(Code)
Interpret the field as a boolean, mainly for checkbox widgets. Implemented for Strings, Integers etc. as well as Booleans because databases do not support booleans cleanly.



getBooleanValue
public boolean getBooleanValue()(Code)



getDataField
public Object getDataField()(Code)



getDataName
public String getDataName()(Code)
Name used to idenify the column in a data source. Defaults to name if null.



getDisplayLength
public int getDisplayLength()(Code)



getExtraProperties
public Object getExtraProperties()(Code)



getMaxLength
public int getMaxLength()(Code)



getOptions
public List getOptions()(Code)



getText
public String getText()(Code)
Return the text representation of this field. Normally just format(), but if the field failed to validate then returns the raw text actually entered by the user.

This is what is used to set values of etc. See class docs.

(Not cached, may involve Integer.toString etc.)




getValue
public Object getValue()(Code)
Just casts value to correct type. Nulls returned as nulls, including booleans.



getValue
public T getValue(T defalt)(Code)



getValueClass
abstract public Class getValueClass()(Code)
Returns the class for which the value must be a subclass.

Also used to find the set*() method of the bean by WBeanUtils.




getWidget
public String getWidget()(Code)
The widget, eg radiobutton, text, select...



isNotRetrieved
public boolean isNotRetrieved()(Code)



isReadOnly
public boolean isReadOnly()(Code)



isRequired
public boolean isRequired()(Code)



onValidateAlways
protected void onValidateAlways() throws Exception(Code)
Always called regardless of whether form wasSubmitted() or value is null. Called after onValidateNotNull.



onValidateNotNull
protected void onValidateNotNull() throws Exception(Code)
Override this method to add extra validation. Called after required and data checks but before all other fields have been validated.

Note that this is ALWAYS called even if the form was not submitted, but is ONLY called if the field is not NULL.




parse
abstract protected void parse(String rawText) throws Exception(Code)
Parse text and store it as the value. Should be fairly forgiving in what it accepts, and should parse whatever format() produces.



setAnchorHRef
public void setAnchorHRef(String anchorHRef)(Code)



setDataField
public WField setDataField(Object dataField)(Code)



setDataName
public WField setDataName(String dataName)(Code)



setDisplayLength
public F setDisplayLength(int displayLength)(Code)



setExtraProperties
public WField setExtraProperties(Object extraProperties)(Code)



setMaxLength
public F setMaxLength(int maxLength)(Code)



setNotRetrieved
public WField setNotRetrieved(boolean notRetrieved)(Code)



setOptions
public void setOptions(List options)(Code)



setPostedText
public WField setPostedText(String text)(Code)
Sets the initial value of the raw text field, typically directly from a HttpRequest.parameter.

Called by the framework or test cases between doInitialize and doProcess, the latter which then parses it to a getValue.

Also trims spaces and converts "" to null.




setReadOnly
public F setReadOnly(boolean readOnly)(Code)



setRequired
public F setRequired(boolean required)(Code)



setValue
public WField setValue(Object value)(Code)
Set the value, must be the correct type, eg. String for WFieldString, Integer for WFieldInteger.



setWidget
public void setWidget(String widget)(Code)



toString
public String toString()(Code)



validateField
void validateField() throws Exception(Code)
Called by doProcess to validates the field and parses it into the value.

A range of common formatting exceptions are converted to WValidationExceptions, but as Java is totally inconsistent this is not clean. But common real errors such as NullPointerException will not be converted. (It is not fatal if some non-validation exceptions are trapped, the form will be rejected either way. But we do not want to make implementors of WData to be dependent on SimpleWebApp.)
throws:
  simpleorm.simplewebapp.core.WValidationException - to report user errors




Fields inherited from simpleorm.simplewebapp.core.WFieldNode
WPagelet pagelet(Code)(Java Doc)
String shortName(Code)(Java Doc)

Methods inherited from simpleorm.simplewebapp.core.WFieldNode
public String getHtmlName()(Code)(Java Doc)
public String getName()(Code)(Java Doc)
public WPage getPage()(Code)(Java Doc)
public WPagelet getPagelet()(Code)(Java Doc)
public String getPrompt()(Code)(Java Doc)
void setPagelet(WPagelet pageletp, WPage page)(Code)(Java Doc)

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.