public interface Dependency
A typical example includes filling later select/popup values based on the user chosen value of an earlier select in the form. So, for example, if the user chooses a country, then the later select shows the states just for that country.
There are several ways to handle dependency changes:
Orthogonal to all this is field and form validation. Validation only makes sense after we have displayed the updated fields to the user For example, initially a country popup may be empty and a state popup may be empty. When the user selects a country, then the form is submitted. At that point, the states popup is still empty and we should *not* validate the states data (i.e., not show the user a message that a state must be chosen or show a validation error for any other fields which the user hasn't filled out yet).
Validation can always be controlled by enabled/disabled flag on the field since field validators are not run for fields that are disabled. In addition, any time a field has new dependent values, the form is not validated by field validators.
Modifier and Type | Method and Description |
---|---|
Object |
getInitialValues(Field f)
Returns the initial values for the target field These are the values that
are displayed when the form is first rendered.
|
boolean |
isSubmitDataValid(FormData fd)
Returns true if the submitted values are in a valid range of values.
|
void |
renderDependencyData(FormData fd,
Writer writer)
Writes out data to keep track of dependency state.
|
void |
setDependencyDataFromSubmit(FormData fd,
javax.servlet.http.HttpServletRequest req)
The inverse of
renderDependencyData , sets any depedency data submitted
as part of the form. |
void |
updateValues(FormData fd,
javax.servlet.http.HttpServletRequest req)
Sets new values for target field in the FormData object.
|
void updateValues(FormData fd, javax.servlet.http.HttpServletRequest req) throws DependencyException
Note:This method invoke FormData.setDependencyUpdated()
if it sets new values in the formdata object. New values are values that
are different from the values that were last displayed to the client.
There are 2 conditions that typically must be satisfied for this to be true:
DependencyException
void setDependencyDataFromSubmit(FormData fd, javax.servlet.http.HttpServletRequest req)
renderDependencyData
, sets any depedency data submitted
as part of the form. This data is set in the specified FormData
object
and can be later used by the updateValues
method.void renderDependencyData(FormData fd, Writer writer) throws SQLException, IOException
SQLException
IOException
Object getInitialValues(Field f)
If there is no initial data, the returned object can also be null or an empty data object, depending on what the target field expects when there is no data.
boolean isSubmitDataValid(FormData fd)
If this method is not applicable, this method should return true every time.