Wednesday, April 4, 2012

JSF Managed Bean

MangedBean in JSF:

Managed Beans are the mere POJO that represents model of the JSF application and are managed by the JSF container. Managed Beans are to be registered in the JSF container through Faces Config xml in JSF1.2 and via annotations in JSF2.0 onwards. By registering it in annotation entry in the faces Config can be avoided. But still one can register managed bean in Faces Config without using annotations in JSF2.0. The criteria for managed bean are same as java bean conventions.

Registering a managed bean in Faces Config (JSF 1.2) :


Sample Managed Bean:

               public class TestBean {

                       private int id;
                       Private String name;

                      /** Getters and setters for Properties **/

Registering in JSF2.0 :


              public class TestBean {

Binding Managed Bean in XHTML:
               <h:inputText value="#{}"></h:inputText>

No comments:

Post a Comment