top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Explain different ways of declaring a managed bean in JSF?

0 votes
410 views
Explain different ways of declaring a managed bean in JSF?
posted Nov 19, 2017 by Jon Deck

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The different ways of declaring a managed bean in JSF:

1. Use @ManagedBean annotation in the java class indicating that the class is a managed bean as:

@ManagedBean(name="Greetings", eager="true")

2. If the name attribute is not specified the name is defaulted to the class name as java naming standards.
For example class Car will be named “car” and CarDetails will be named “carDetails”.

Declare the managed bean in faces-config.xml file as:

<managed-bean>
    <managed-bean-name>Greetings</managed-bean-name>
    <managed-bean-class>com.Greetings.Greetings</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
answer Nov 22, 2017 by Frank Lee
...