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) :
<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-bean>
Sample Managed Bean:
public class TestBean {
private int id;
Private String name;
/** Getters and setters for Properties **/
}
Registering in JSF2.0 :
@ManagedBean
@RequestScoped
public class TestBean {
-------------------
---------------------------
Binding Managed Bean in XHTML:
<h:inputText value="#{testBean.name}"></h:inputText>
No comments:
Post a Comment