Class TestDependency
java.lang.Object
fc.web.forms.TestDependency
- All Implemented Interfaces:
Dependency
A test dependency implementation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the initial values for the target field These are the values that are displayed when the form is first rendered.booleanReturns true if the submitted values are in a valid range of values.voidrenderDependencyData(FormData fd, Writer out) Writes out data to keep track of dependency state.voidsetDependencyDataFromSubmit(FormData fd, jakarta.servlet.http.HttpServletRequest req) The inverse ofDependency.renderDependencyData(fc.web.forms.FormData,java.io.Writer), sets any depedency data submitted as part of the form.toString()voidupdateValues(FormData fd, jakarta.servlet.http.HttpServletRequest req) Sets new values for target field in the FormData object.
-
Constructor Details
-
TestDependency
-
-
Method Details
-
getInitialValues
Description copied from interface:DependencyReturns the initial values for the target field These are the values that are displayed when the form is first rendered. The returned object is of a type that is suitable for the data of the target field. (typically an instance of a static inner data class of that field).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.
- Specified by:
getInitialValuesin interfaceDependency
-
updateValues
public void updateValues(FormData fd, jakarta.servlet.http.HttpServletRequest req) throws DependencyException Description copied from interface:DependencySets new values for target field in the FormData object. The target field then uses those values to render itself to the client. The data should be saved in FormData with the field name as the key.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:
- Source not null: The source fields must have some data. For example, a country popup needs to be selected to some country value before the target dependent field (a state popup) can be populated. If no country is selected, we cannot calculate a dependent state value.
- Source changed: The source fields must have different data than the last time the form was rendered (which means that the client made a different selection/choice). For example, previously, the source field could have been 'usa'. The client then either changes that to 'uk' or leaves it alone. The last_value (which is rendered as a hidden field in the form) in conjunction with the submittd value of the source field(s) can be used to figure out if there was a dependency change. If the source value is 'usa' and the last_value is 'usa', then we know there is no need for any dependency updates (since the usa values are already shown to the user).
- Specified by:
updateValuesin interfaceDependency- Throws:
DependencyException
-
setDependencyDataFromSubmit
Description copied from interface:DependencyThe inverse ofDependency.renderDependencyData(fc.web.forms.FormData,java.io.Writer), sets any depedency data submitted as part of the form. This data is set in the specifiedFormDataobject and can be later used by theDependency.updateValues(fc.web.forms.FormData,jakarta.servlet.http.HttpServletRequest)method.- Specified by:
setDependencyDataFromSubmitin interfaceDependency
-
renderDependencyData
Description copied from interface:DependencyWrites out data to keep track of dependency state. This data is typically the last selected values of some source field (say last selected source country for a target dependent state field) and usually written out as a hidden field in the form.- Specified by:
renderDependencyDatain interfaceDependency- Throws:
SQLExceptionIOException
-
isSubmitDataValid
Description copied from interface:DependencyReturns true if the submitted values are in a valid range of values. For ultra-secure applications, the validity can be computed every time by recomputing/retrieving the dependent data and of-course, database constraints should always be employed.If this method is not applicable, this method should return true every time.
- Specified by:
isSubmitDataValidin interfaceDependency
-
toString
-