JSF component's value, local value and submitted value
December 28, 2005 3 Comments
I’ve observed that some people who are trying to create custom components, seem to be confused with the three different value types of an uiinput component. These are, “value”, “local value” and “submitted value”
* Actually the differences are simple and come from the life cycle, when the user submits a form all the values are passed
to the server as strings. In the apply request values phase, these string values must be converted and validated before the
model update phase can begin.
* At first the value is retrieved from the request and during decoding the “submitted value” is set by the component. This submitted value has nothing to the with the model and is all about the component. This means the request value is first stored in the component.
* Later the conversion stage begins, if there are any converter is defined, this converter takes this submitted value and applies the getAsObject method on this value. Now the submitted value of the component is converted and set as the “local value”.
* Finally if any, validators come up and validate the local value. Rest is trivial from now on. if the local value is valid, it is set to the binded model variable. This happens in update model phase.
* Component’s value refers to the “binded model value” actually, so whenever you call getValue, it will bring it to you. Local value and submitted value are the ones used to change it. You must use getValue() during encoding because submitted value and local value are set to null already.
That’s all about the three “value” types of a jsf component, as seen above it is all about the lifecycle of JSF🙂