Access one Managed Bean from another in JSF 2.0 | Techartifact

Requirement- Access one Managed Bean from another in JSF

Solution- There are two ways-

Dependency Injection

We can use JSF 2 @ManagedProperty annotation

In the managed bean add a @ManagedProperty annotation to the related property

public class CurrentBean 

    private RequiredBean requiredBean;

    public RequiredBean getRequiredBean()
        return requiredBean;

    public void setRequiredBean(RequiredBean requiredBean)
        this.requiredBean= requiredBean;

    // ....


Usingthrough faces-config.xml



Following are the constraints:

-> The current bean must have scope which is the same as or shorter than the required bean
-> The using bean must have a property-setter method which takes the required bean as a parameter
-> The beans cannot have managed dependencies on each other.


I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube