getting binding of component from one managed bean to another

Today i got one of the requirment to get the binding of some component which is binding in another managed bean.
This is something tedious requirment i have.. Well in JSF 2.0 you can get very easily by using below code

 
        FacesContext context = FacesContext.getCurrentInstance();
        BEAN bean = (RegionNavigationListener)context.getApplication().evaluateExpressionGet(context, "#{BEAN}", BEAN.class);


You can write above code as below as well

FacesContext fctx = FacesContext.getCurrentInstance();
Application application = fctx.getApplication();
ExpressionFactory expressionFactory = application.getExpressionFactory();
ELContext context = fctx.getELContext();
ValueExpression createValueExpression = expressionFactory.createValueExpression(context, "#{pageFlowScope.PageFlowScopeBean}",PageFlowScopeClass.class);
PageFlowScopeClass pageFlowScopeInstance =(PageFlowScopeClass) createValueExpression.getValue(context);

Vinay

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