See the following code:
<h:inputText id="name" value="#{jsfBean.name}" binding="#{jsfBean.htmlInputText}"/>
In the above example we are using the binding attribute to link with the server side bean property. I want to know what is the difference in using this attribute and not using this attribute.
A JSF "binding" is a binding of the actual JSF UI component to a property. In over 99 cases out of 100, you would use the "value=" attribute, since it's only the control's backing property value you care about dealing with in the backing bean.
To bind a component's value to a managed bean property, you specify the name of the bean and the property using the value attribute.
With binding attribute you are mapping the actual component and NOT the component's value. For e.g the property in backing bean for your sample looks like below
UIInput htmlInputText= null;
...
public void setHtmlInputText(UIInput userNoComponent) {
this.userNoComponent = userNoComponent;
}
public UIInput getHtmlInputText() {
return userNoComponent;
}
Binding a component instance to a bean property has these advantages:
Find more details in this tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With