|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.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 FormMapper |
formMapper
|
protected static org.apache.log4j.Logger |
localLogger
|
protected StateMap |
statemap
|
protected List |
validators
|
protected Locale |
zloc
|
Constructor Summary | |
DefaultFormMap()
Default constructor (uses DefaultFormMapper) |
|
DefaultFormMap(String iprefix)
Prefix constructor (uses PrefixFormMapper) |
Method Summary | |
void |
clearState()
clear all state information |
FormElement |
defineElement(FormElement element)
This defines an element to be mapped by this form, using the key from the FormElement. |
FormElement |
defineElement(String key,
FormElement element)
This defines an element to be mapped by this form, using a manually specified key. |
FormValidator |
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 |
FormElement |
getElement(String key)
Get an element by key |
Map |
getElements()
return a List with containing all the defined elements in this FormMap |
FormMapper |
getFormMapper()
Get the FormMapper for this map |
Locale |
getLocale()
Get the working locale for this form |
Object |
getState(Object key)
get a property in this StateMap |
Set |
getStateKeys()
get a keyset for this StateMap (whether or not the set is backed by the data store depends on the implementation) |
Map |
getStateStore()
get a copy of the underlying Map |
Object |
getVal(String key)
Get the value for a given key. |
Object |
getVal(String key,
Object dflt)
|
Object[] |
getVals(String key)
Get an array of values for a given key. |
Object[] |
getVals(String key,
Object[] dflt)
|
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(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. |
FormElement |
mapElement(String key,
Object origVal)
Map an individual element by specifiying the key and origVal. |
void |
putState(Object key,
Object val)
set a property in this StateMap |
Object |
removeState(Object key)
remove a property in this StateMap |
void |
setFormMapper(FormMapper imapper)
Set the FormMapper for this map |
void |
setLocale(Locale iloc)
Set the working locale for mapping the elements (null indicates the default locale will be used) |
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
protected Locale zloc
protected FormMapper formMapper
Constructor Detail |
public DefaultFormMap()
public DefaultFormMap(String iprefix)
Method Detail |
public FormElement defineElement(FormElement element)
defineElement
in interface FormMap
element
- a FormElement to be mapped by this form
public FormElement defineElement(String key, FormElement element)
defineElement
in interface FormMap
key
- a manually specified keyelement
- a FormElement to be mapped by this form
public FormValidator defineValidator(FormValidator validator)
defineValidator
in interface FormMap
validator
- a form validator to be applied to the entire form
public 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(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 FormElement mapElement(String key, Object origVal)
mapElement
in interface FormMap
key
- the form map keyorigVal
- the orig val to be mapped
MappingException
- if for some reason the value cannot be mapped successfullypublic 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 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 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 getVal(String key, Object dflt)
getVal
in interface FormMap
public Object[] getVals(String key)
getVals
in interface FormMap
key
- the key which uniquely identifies this FormElement
public Object[] getVals(String key, Object[] dflt)
getVals
in interface FormMap
public void setLocale(Locale iloc)
setLocale
in interface FormMap
public Locale getLocale()
getLocale
in interface FormMap
public void setFormMapper(FormMapper imapper)
setFormMapper
in interface FormMap
public FormMapper getFormMapper()
getFormMapper
in interface FormMap
public 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 Set getStateKeys()
getStateKeys
in interface StateMap
public Map getStateStore()
getStateStore
in interface StateMap
public void clearState()
clearState
in interface StateMap
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |