Initializing the MangedBean property:
Managed beans shall be initialized on the object creation and this shall be performed using configuration in Faces Config xml in JSF1.2 and using annotations in JSF2.0
Initializing a property in JSF1.2:
<managed-bean>
<managed-bean-name>testBean</managed-bean-name>
<managed-bean-class>com.test.TestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>name</property-name>
<property-class>java.lang.String</property-class>
<value>Enter the Name</value>
</managed-property>
</managed-bean>
Initializing the same in JSF2.0: Take a look at the annotation @ManagedProperty introduced in JSF2.0 and the value attribute holds the default value to be initialized.
@ManagedBean
@RequestScoped
public class TestBean {
@ManagedProperty(value="Enter the Name")
private String name;
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the name
*/
public String getName() {
return name;
}
-----------------------------------------------
No comments:
Post a Comment