Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the advantages of using binding attribute in JSF? [duplicate]

Tags:

jsf

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.

like image 715
Krishna Avatar asked Dec 26 '10 06:12

Krishna


People also ask

What is the use of binding attribute in JSF?

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.

Which attribute is used to bind the data entered in the form with the properties of bean class?

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.


1 Answers

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:

  • The backing bean can programmatically modify component attributes.
  • The backing bean can instantiate
    components rather than let the page
    author do so.

Find more details in this tutorial

like image 140
Aravind Yarram Avatar answered Nov 02 '22 12:11

Aravind Yarram