Wednesday, April 4, 2012

Initializing Managed Bean Property

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:


                                <value>Enter the Name</value>


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.


public class TestBean {

  @ManagedProperty(value="Enter the Name")
   private String name;
     * @param name the name to set
    public void setName(String name) {
 = name;
     * @return the name
     public String getName() {
         return name;


No comments:

Post a Comment