difference between value and component binding in JSF
Before reading Balusc’s blog post I thought there is no big difference between the value and component binding in the Java Server faces but after that post I got clear idea about component and value binding. there is some big difference between them. A lot of things happens in the life cycle because of that component binding behave like Java Swing application. if we look into the internals of the JSF lifecycle we can conclude some important things.’
generally in the JSF life cycle at the time of “validation Phase” the user submitted value will set into the component’s value but it should pass the validation phase. So the user summited value will available in for the value change event method.
In Component binding:
1. Restore view.
The components are restored in the UIViewRoot and set in the eventual component bindings.
2. Apply request values.
Nothing to see here. Behind the scenes the submitted form values are obtained as request parameters and set in the relevant components in the UIViewRoot, for example inputComponent.setSubmittedValue(“test”).
3. Process validations.
The submitted values are passed through the converter getAsObject() method and validated by the validator. If the conversion and validation succeeds, then behind the scenes the inputComponent.setValue(submittedValue) and inputComponent.setSubmittedValue(null) will be executed. Finally the valueChangeListener method is invoked.
4. Update model values.
The converted and validated values will now be set in the value binding setters of the backing bean. E.g. myBean.setInputValue(inputComponent.getValue()).
5. Invoke application.
The real processing of the form submission happens here.
6. Render response.
The values to be shown are retrieved from the value binding getters in the backing bean. If a converter is definied, then the value will be passed through the converter getAsString() method and the result will be shown in the form.
In value Binding:
In the Value binding approach also works in the same way but only the difference is here the component’s value is referred by a String variable in the backing bean so this variable is getting update with user submitted value at the time of “Update-model Phase”, it is getting update by copying the data from component’s local value So thats why the user submitted value is not available at the time of value change event for that every one uses “event.getNewValue()” method to retrieve the user submitted value even if use the value binding we can get the user submitted data by accessing “UIRoot”
Ex: evt.getComponent().findComponent(”Name”))
So there are some other issues:
* At the time of Immediate true for the command button.
the best resource for this condition
So if any one have different issues about this article please post it in the comments then if that is worth then I will consider and I can display that in my article so it will help the others.
