JSF component's value, local value and submitted value

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🙂

3 Responses to JSF component's value, local value and submitted value

  1. cm says:

    Your entry confused me a lot🙂

    To be precise, your statement is only true when using valuebinding, which is not necessarily the case. But it is correct that you should use getValue(), which is always safe.

    setValue() -> set local value (no VB)
    getValue() -> like normal property (first local value, then VB)
    getLocalValue() -> get components local property

    hopp FCB😉

  2. Anonymous says:

    55

  3. alex_ro_bv says:

    hi, I read your article, but I’ve got a problem… probably not the best place to ask, but here it goes: I’ve got an id of an input and a value and I can’t for the love of God to insert it in the component. it throws an exception when trying it, but it seems to obtain the component with
    UIViewRoot root = facesContext.getViewRoot();
    UIInput input = (UIInput )root.findComponent(key);
    or just not throwing an exception here. What should I use ?
    input.setValue(value); doesn’t work! I try doing this in a phaseListener before_render_response phase. Can you help me?

%d bloggers like this: