What is Managed Bean in JSF page


What if you want your JSF page to access the properties or custom methods present in a Java Bean class. In this case, the bean class should be managed by the JSF page. That means, the JSF page can able read the JAVA BEAN property to display its UI components and update the JAVA BEAN property by UI form submission. Making a normal POJO into JSF controlled bean is called as Managed Bean.

Simply put a @ManagedBean annotation on top of a Java class converts a normal Java Bean class into a Managed Bean Class.

The following Java Class is a Managed Bean class. A JSF page can refer these bean properties by its bean Name ‘user’.




The name parameter is optional. In that case, JSF uses the class name to refer the bean properties. The only change the JSF applies is changing its first character of the class name into lower case, that is  User to user. Now look at the following example


Tha following Java class is a Managed Bean. If you notice, Ther is  an annotation @ManagedBean on top of the class




JSF referring the Managed bean using expression language. The outputText calls the getUsername() method and inputText() calls setUsername() method on form submition. 




It’s not always JSF only refer the setter and getter methods in a Managed bean. JSF can call any custom methods or properties or enum in a Managed Bean. I will cover those in next posts

govindan What is Managed Bean in JSF page
Connect me


Thank you for visiting my personal blog. Myself Govindan, Software Developer by profession since 2006 and hence I started this blog early in 2016 and ever since I've been writing about technologies experienced and learnings of everyday life.

The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.

Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
govindan What is Managed Bean in JSF page
Connect me
By | 2017-09-30T16:40:08+00:00 September 30th, 2017|Categories: JSF|Tags: |0 Comments
Like us on Facebook.