|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.FormData
Manages the data associated with forms and other remote sources.
The basic task of a FormData
object is to transform
a set of key-value string pairs into a validated set of Java data
objects for use in subsequent processing. In most cases the original
data is an HTTP request.
To perform the transformation, a separate instance of
FormModel
is used to specify the name and basic data
type of each expected parameter in the set, as well as any
additional validation steps required. The FormData
stores both the transformed data objects and any validation
error messages associated with an individual parameter or the
form as a whole. Once the data has been validated, individual data
objects may be queried from a FormData
using the
standard get
method of the Map
interface.
FormData
objects may also be used to control the
entire lifecycle of self-validating forms, which report errors to
the user in the context of the form itself, rather than on a
separate page.
See the Forms API Developer Guide for details on using the
FormData
class.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
static String |
versionId
|
Constructor Summary | |
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
|
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request,
boolean isSubmission)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
|
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request,
boolean isSubmission,
FormData fallback)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
|
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request,
Locale locale)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
|
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request,
Locale locale,
boolean isSubmission)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
|
FormData(FormModel model,
javax.servlet.http.HttpServletRequest request,
Locale locale,
boolean isSubmission,
FormData fallback)
Constructs a new FormData object containing the
transformed and validated query parameters from an HTTP request. |
Method Summary | |
void |
addError(GlobalizedMessage message)
Reports a validation error on the form as a whole. |
void |
addError(String message)
Reports a validation error on the form as a whole. |
void |
addError(String name,
GlobalizedMessage message)
Adds an error message to the ParameterData object associated with the parameter model identified by name . |
void |
addError(String name,
String message)
Adds an error message to the ParameterData object associated with the parameter model identified by name . |
String |
asString()
Converts to a String. |
void |
clear()
|
Object |
clone()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set |
entrySet()
|
void |
forceValidate(PageState state)
Validates this FormData object against its
form model, regardless of whether the object is currently
valid. |
Object |
get(Object key)
Returns the value contained by the ParameterData object named by key . |
Object |
get(ParameterModel m)
Deprecated. Use get(m.getName()) instead, and then manually check for model identity |
Iterator |
getAllErrors()
Returns an iterator over all of the errors on this form. |
Date |
getDate(Object key)
Retrieves a date object for the specified parameter name. |
Iterator |
getErrors()
Returns an iterator over all the errors on this form that are not associated with any particular parameter. |
Iterator |
getErrors(String name)
Returns the errors associated with the specified parameter. |
Integer |
getInteger(Object key)
Retrieves an integer object for the specified parameter name. |
ParameterData |
getParameter(String name)
Gets the specified ParameterData object. |
Collection |
getParameters()
Returns a collection of all the ParameterData objects. |
String |
getString(Object key)
Retrieves a String object for the specified parameter name. |
void |
invalidate()
Set isValid to false . |
boolean |
isEmpty()
|
boolean |
isSubmission()
Determines whether this request represents a submission event. |
boolean |
isTransformed()
Determines whether the key-value string pairs in the request have been transformed into Java data objects. |
boolean |
isValid()
Determines whether any errors were found during validation of a form submission. |
Set |
keySet()
|
Object |
put(Object key,
Object value)
|
void |
putAll(Map t)
|
Object |
remove(Object key)
|
void |
setInvalid()
Deprecated. Use invalidate() instead |
void |
setParameter(String name,
ParameterData value)
Sets the ParameterData object identified by the name in this FormData Object. |
int |
size()
|
String |
toString()
|
void |
validate(PageState state)
Validates this FormData object according to its
form model. |
Collection |
values()
|
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Field Detail |
public static final String versionId
Constructor Detail |
public FormData(FormModel model, javax.servlet.http.HttpServletRequest request) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
model
- a FormModel
describing the parameters
and validation constraints for this requestrequest
- an HTTP request object passed from the servlet
container
FormProcessException
- if an error occurs.public FormData(FormModel model, javax.servlet.http.HttpServletRequest request, boolean isSubmission) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
model
- a FormModel
describing the parameters
and validation constraints for this requestrequest
- an HTTP request object passed from the servlet
containerisSubmission
- true
if the request should be treated
as a form submission by the user
FormProcessException
- if an error occurs.public FormData(FormModel model, javax.servlet.http.HttpServletRequest request, boolean isSubmission, FormData fallback) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
model
- a FormModel
describing the parameters
and validation constraints for this requestrequest
- an HTTP request object passed from the servlet
containerisSubmission
- true
if the request should be treated
as a form submission by the userfallback
- a fallback FormData object. If a value for
a parameter in the form model model
is not in
the current request parameters, the fallback
object is
searched.
FormProcessException
- if an error occurspublic FormData(FormModel model, javax.servlet.http.HttpServletRequest request, Locale locale) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
Error messages are provided in the specified locale.
model
- A FormModel
describing the parameters
and validation constraints for this request.request
- An HTTP request object passed from the servlet
container.locale
- The locale for which all error messages will be
prepared. This may be used in a multilingual environment to
tailor the output to the preferences or geographic location of
individual users on a per-request basis.
FormProcessException
- if an error occurspublic FormData(FormModel model, javax.servlet.http.HttpServletRequest request, Locale locale, boolean isSubmission) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
Error messages are provided in the specified locale.
model
- A FormModel
describing the parameters
and validation constraints for this request.request
- An HTTP request object passed from the servlet
container.locale
- The locale for which all error messages will be
prepared. This may be used in a multilingual environment to
tailor the output to the preferences or geographic location of
individual users on a per-request basis.isSubmission
- true
if the request should be treated
as a form submission by the user.
FormProcessException
- if an error occurspublic FormData(FormModel model, javax.servlet.http.HttpServletRequest request, Locale locale, boolean isSubmission, FormData fallback) throws FormProcessException
FormData
object containing the
transformed and validated query parameters from an HTTP request.
Error messages are provided in the specified locale.
model
- A FormModel
describing the parameters
and validation constraints for this request.request
- An HTTP request object passed from the servlet
container.locale
- The locale for which all error messages will be
prepared. This may be used in a multilingual environment to
tailor the output to the preferences or geographic location of
individual users on a per-request basis.isSubmission
- true
if the request should be treated
as a form submission by the user.fallback
- a fallback FormData object. If a value for
a parameter in the form model model
is not in
the current request parameters, the fallback
object is
searched.
FormProcessException
- if an error occursMethod Detail |
public void validate(PageState state)
FormData
object according to its
form model. If the FormData
is already valid,
does nothing.
state
- describes the current page statepublic void forceValidate(PageState state)
FormData
object against its
form model, regardless of whether the object is currently
valid.
state
- describes the current page statepublic void addError(String message)
message
- a String of the error messagepublic void addError(GlobalizedMessage message)
message
- the error messagepublic void addError(String name, String message)
name
.
name
- the name of the parameter model to whose
ParameterData the error message will be addedmessage
- the text of the error message to addpublic void addError(String name, GlobalizedMessage message)
name
.
name
- the name of the parameter model to whose
ParameterData the error message will be addedmessage
- the text of the error message to addpublic Iterator getErrors(String name)
name
- the name of the parameter whose errors we are interested in
public Iterator getErrors()
public Iterator getAllErrors()
public ParameterData getParameter(String name)
name
- the name of the parameterModel to retrieve
public void setParameter(String name, ParameterData value)
name
- the name of the parameterModelpublic final Collection getParameters()
ParameterData
objects.
ParameterData
objects.public final boolean isSubmission()
true
if this request represents a submission event;
false
if it represents an initialization event.public final boolean isTransformed()
true
if the key-value string pairs
have been transformed into Java data objects;
false
otherwise.public final boolean isValid()
true
if no errors were found; false
otherwise.public void setInvalid()
false
. We do not allow programmers
to manually toggle the isValid value to true
.
Hence this method takes no
arguments and only sets isValid flag to false
public final void invalidate()
false
. We do not allow programmers
to manually toggle the isValid value to true
.
public void clear()
clear
in interface Map
public boolean containsKey(Object key)
containsKey
in interface Map
public boolean containsValue(Object value)
containsValue
in interface Map
public Set entrySet()
entrySet
in interface Map
public Object get(Object key) throws IllegalArgumentException
key
.
If no key is found, throws IllegalArgumentException.
get
in interface Map
key
- the parameter data object to retrieve
IllegalArgumentException
- thrown when the key
is not a valid parameter.public Object get(ParameterModel m)
public Date getDate(Object key)
key
- the object to retrieve
public Integer getInteger(Object key)
key
- the object to retrieve
public String getString(Object key)
key
- the object to retrieve
public boolean isEmpty()
isEmpty
in interface Map
public Set keySet()
keySet
in interface Map
public Object put(Object key, Object value)
put
in interface Map
public void putAll(Map t)
putAll
in interface Map
public Object remove(Object key)
remove
in interface Map
public int size()
size
in interface Map
public Collection values()
values
in interface Map
public Object clone() throws CloneNotSupportedException
CloneNotSupportedException
public String toString()
public String asString()
toString()
returns all errors.
this
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |