You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2007/09/13 11:02:47 UTC

[Myfaces Wiki] Update of "AccessingOneManagedBeanFromAnother" by OgnjenBlagojevic

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by OgnjenBlagojevic:
http://wiki.apache.org/myfaces/AccessingOneManagedBeanFromAnother

------------------------------------------------------------------------------
  
  ==== Using Lookup ====
  
- The following java code can be used to explicitly look up an arbitrary managed bean by name:
+ The following java code can be used in MyFaces 1.1 to explicitly look up an arbitrary managed bean by name:
  {{{
  FacesContext facesContext = FacesContext.getCurrentInstance();
  NeededBean neededBean
      = (NeededBean) facesContext.getApplication()
-       .getVariableResolver().resolveVariable(facesContext, "neededBean");
+         .getVariableResolver().resolveVariable(facesContext, "neededBean");
+ }}}
+ In MyFaces 1.2, that code is deprecated, and preffered version is:
+ {{{
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+ NeededBean neededBean 
+     = (NeededBean) FacesContext.getCurrentInstance().getApplication()
+         .getELResolver().getValue(elContext, null, "neededBean");
  }}}
  Alternately, you can use this code to evaluate any JSF EL expression.
  {{{