Try this, it should work for any Expression but we just use it to fetch
managed bean instances.

  /**
   * @param managedBeanName
   * @return the current instance of the managed bean
   * @see FacesContext#getELContext
   * @see ELContext#getELResolver
   * @see ELResolver
   */
  public static Object getManagedBeanInstance(String managedBeanName) {
    Object object = null;
    FacesContext context = FacesContext.getCurrentInstance();
    if (context != null) {
      ELContext ec = context.getELContext();
      if (ec != null) {
        ELResolver er = ec.getELResolver();
        object = er.getValue(ec, null, managedBeanName);
      }
    }
    return object;
  }


[EMAIL PROTECTED] | www.mizar.com | (360) 945-2643


-----Original Message-----
From: zqzuk [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 13, 2008 10:14 AM
To: [email protected]
Subject: how to access registered bean in code


Hi, I need to access an "application" scoped bean defined in faces-config. I
digged in the forum and did found some answers to tihs, e.g.,
"FacesContext.getCurrentInstance().getApplication().getVariableResolver().re
solveVariable(FacesContext.getCurrentInstance
(), "myBean1");",  

However this is deprecated version and when I am looking at JSF 1.2
documentation, I cannot figure out what is the equivalent way to do this...

Please could you give me some hints, many thanks!


-- 
View this message in context:
http://www.nabble.com/how-to-access-registered-bean-in-code-tp16661140p16661
140.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to