|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.enhydra.barracuda.core.forms.DefaultFormMap
This class provides the default implementation of a FormMap.
A FormMap is used to provide a virtual representation of a form. It can contain any number of unique FormElements, and it can also be associated with FormValidators. The primary function of a form map is to:
Field Summary | |
protected static Locale |
defaultLoc
|
protected Map |
elements
|
protected static org.apache.log4j.Logger |
localLogger
|
protected StateMap |
statemap
|
protected List |
validators
|
Constructor Summary | |
DefaultFormMap()
|
Method Summary | |
void |
clearState()
clear all state information |
void |
defineElement(FormElement element)
This defines an element to be mapped by this form, using the key from the FormElement. |
void |
defineElement(String key,
FormElement element)
This defines an element to be mapped by this form. |
void |
defineValidator(FormValidator validator)
This defines a validator for the entire form. |
boolean |
exists(String key)
Return true if an element exists and its value is not null |
Boolean |
getBooleanVal(String key)
Get an Boolean value from the map |
Boolean |
getBooleanVal(String key,
Boolean dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Date |
getDateVal(String key)
Get an Date value from the map |
Date |
getDateVal(String key,
Date dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Double |
getDoubleVal(String key)
Get an Double value from the map |
Double |
getDoubleVal(String key,
Double dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
FormElement |
getElement(String key)
Get an element by key |
Map |
getElements()
return a map with containing all the elements in this form map |
Map |
getElementVals()
Get a map with containing the values for all the elements in this form map |
Float |
getFloatVal(String key)
Get an Float value from the map |
Float |
getFloatVal(String key,
Float dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Integer |
getIntegerVal(String key)
Get an Integer value from the map |
Integer |
getIntegerVal(String key,
Integer dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Long |
getLongVal(String key)
Get an Long value from the map |
Long |
getLongVal(String key,
Long dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Short |
getShortVal(String key)
Get an Short value from the map |
Short |
getShortVal(String key,
Short dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Object |
getState(Object key)
get a property in this StateMap |
List |
getStateKeys()
get a list of the keys for this StateMap |
Map |
getStateValues()
get a copy of the underlying Map |
String |
getStringVal(String key)
Get a String value from the map |
String |
getStringVal(String key,
String dflt)
Get the value for a given key, defaulting accordingly if the value is null. |
Object |
getVal(String key)
Get the value for a given key. |
Object[] |
getVals(String key)
Get an array of values for a given key. |
boolean |
isNull(Object val)
This method defines what the FormMap identifies as null-value. |
FormMap |
map(javax.servlet.ServletRequest req)
This is where we actually take an incoming form (in the form of a ServletRequest) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(javax.servlet.ServletRequest req,
Locale loc)
This is where we actually take an incoming form (in the form of a ServletRequest) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(javax.servlet.ServletRequest req,
String prefix)
This is where we actually take an incoming form (in the form of a ServletRequest) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(javax.servlet.ServletRequest req,
String prefix,
Locale loc)
This is where we actually take an incoming form (in the form of a ServletRequest) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(StateMap map)
This is where we actually take an incoming form (in the form of a StateMap) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(StateMap map,
Locale loc)
This is where we actually take an incoming form (in the form of a StateMap) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(StateMap map,
String prefix)
This is where we actually take an incoming form (in the form of a StateMap) and map it using the definitions supplied by all the FormElements. |
FormMap |
map(StateMap map,
String prefix,
Locale loc)
This is where we actually take an incoming form (in the form of a StateMap) and map it using the definitions supplied by all the FormElements. |
FormElement |
mapElement(String key,
Object origVal)
This allows you to map a single value (as opposed to passing in a whole statemap or request). |
FormElement |
mapElement(String key,
Object origVal,
Locale loc)
This allows you to map a single value (as opposed to passing in a whole statemap or request). |
void |
putState(Object key,
Object val)
set a property in this StateMap |
Object |
removeState(Object key)
remove a property in this StateMap |
void |
setVal(String key,
Object val)
Manually set the value of an element. |
FormMap |
validate(boolean deferExceptions)
Validate the entire form (both form level and elements). |
FormMap |
validateElements(boolean deferExceptions)
Validate just the elements (not the form) |
FormMap |
validateForm(boolean deferExceptions)
Validate just the form (not the individual elements) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final org.apache.log4j.Logger localLogger
protected Map elements
protected List validators
protected StateMap statemap
protected static final Locale defaultLoc
Constructor Detail |
public DefaultFormMap()
Method Detail |
public void defineElement(FormElement element)
defineElement
in interface FormMap
element
- a FormElement to be mapped by this formpublic void defineElement(String key, FormElement element)
defineElement
in interface FormMap
key
- the key which uniquely identifies this FormElementelement
- a FormElement to be mapped by this formpublic void defineValidator(FormValidator validator)
defineValidator
in interface FormMap
validator
- a form validator to be applied to the entire formpublic FormMap map(javax.servlet.ServletRequest req)
map
in interface FormMap
req
- the ServletRequest to map paramters from based on
all defined FormElements
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(javax.servlet.ServletRequest req, Locale loc)
map
in interface FormMap
req
- the ServletRequest to map paramters from based on
all defined FormElementsloc
- the locale to use when parsing Dates and other locale dependend
values.
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(javax.servlet.ServletRequest req, String prefix)
map
in interface FormMap
req
- the ServletRequest to map paramters from based on
all defined FormElementsprefix
- the prefix to use when mapping parameters
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(javax.servlet.ServletRequest req, String prefix, Locale loc)
map
in interface FormMap
req
- the ServletRequest to map paramters from based on
all defined FormElementsprefix
- the prefix to use when mapping parametersloc
- the locale to use when parsing Dates and other locale dependend
values.
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(StateMap map)
map
in interface FormMap
map
- the StateMap to map properties from based on
all defined FormElements
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(StateMap map, String prefix)
map
in interface FormMap
map
- the StateMap to map properties from based on
all defined FormElementsprefix
- the prefix to use when mapping parameters
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(StateMap map, Locale loc)
map
in interface FormMap
map
- the StateMap to map properties from based on
all defined FormElementsloc
- the locale to use when parsing Dates and other locale dependend
values.
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormMap map(StateMap map, String prefix, Locale loc)
map
in interface FormMap
map
- the StateMap to map properties from based on
all defined FormElementsprefix
- the prefix to use when mapping parametersloc
- the locale to use when parsing Dates and other locale dependend
values.
MappingException
- if for some reason the value cannot
be mapped successfullypublic FormElement mapElement(String key, Object origVal)
mapElement
in interface FormMap
key
- the name of the element we wish to map toorigVal
- the original value to be mapped
public FormElement mapElement(String key, Object origVal, Locale loc)
mapElement
in interface FormMap
key
- the name of the element we wish to map toorigVal
- the original value to be mappedloc
- the locale to use when parsing Dates and other locale dependant values.
public FormMap validate(boolean deferExceptions) throws ValidationException
validate
in interface FormMap
deferExceptions
- do we want to deferValidation exceptions
and attempt to validate all elements so that we can process
all the exceptions at once
ValidationException
- if the form (or any element within it)
is invalidpublic FormMap validateElements(boolean deferExceptions) throws ValidationException
validateElements
in interface FormMap
deferExceptions
- do we want to deferValidation exceptions
and attempt to validate all elements so that we can process
all the exceptions at once
ValidationException
- if the form (or any element within it)
is invalidpublic FormMap validateForm(boolean deferExceptions) throws ValidationException
validateForm
in interface FormMap
deferExceptions
- do we want to deferValidation exceptions
and attempt to validate all elements so that we can process
all the exceptions at once
ValidationException
- if the form (or any element within it)
is invalidpublic void putState(Object key, Object val)
putState
in interface StateMap
key
- the state key objectval
- the state value objectpublic Object getState(Object key)
getState
in interface StateMap
key
- the state key object
public Object removeState(Object key)
removeState
in interface StateMap
key
- the key object
public List getStateKeys()
getStateKeys
in interface StateMap
public Map getStateValues()
getStateValues
in interface StateMap
public void clearState()
clearState
in interface StateMap
public boolean exists(String key)
exists
in interface FormMap
key
- the key which uniquely identifies this FormElement
public FormElement getElement(String key)
getElement
in interface FormMap
key
- the key which uniquely identifies this FormElement
public Map getElements()
getElements
in interface FormMap
public Map getElementVals()
getElementVals
in interface FormMap
public void setVal(String key, Object val)
setVal
in interface FormMap
key
- the keyval
- the value for the keypublic Object getVal(String key)
getVal
in interface FormMap
key
- the key which uniquely identifies this FormElement
public Object[] getVals(String key)
getVals
in interface FormMap
key
- the key which uniquely identifies this FormElement
public String getStringVal(String key)
getStringVal
in interface FormMap
key
- the form element key
public String getStringVal(String key, String dflt)
getStringVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Boolean getBooleanVal(String key)
getBooleanVal
in interface FormMap
key
- the form element key
public Boolean getBooleanVal(String key, Boolean dflt)
getBooleanVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Integer getIntegerVal(String key)
getIntegerVal
in interface FormMap
key
- the form element key
public Integer getIntegerVal(String key, Integer dflt)
getIntegerVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Date getDateVal(String key)
getDateVal
in interface FormMap
key
- the form element key
public Date getDateVal(String key, Date dflt)
getDateVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Long getLongVal(String key)
getLongVal
in interface FormMap
key
- the form element key
public Long getLongVal(String key, Long dflt)
getLongVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Short getShortVal(String key)
getShortVal
in interface FormMap
key
- the form element key
public Short getShortVal(String key, Short dflt)
getShortVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Double getDoubleVal(String key)
getDoubleVal
in interface FormMap
key
- the form element key
public Double getDoubleVal(String key, Double dflt)
getDoubleVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public Float getFloatVal(String key)
getFloatVal
in interface FormMap
key
- the form element key
public Float getFloatVal(String key, Float dflt)
getFloatVal
in interface FormMap
key
- the key which uniquely identifies this FormElementdflt
- the default value to be used if the underlying value is null
public boolean isNull(Object val)
val
- The value from request or statemap
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |