Hi, I think that parameters set via ui:param are only available in the facelet they are set on.
When using c:set in a template client you have to be careful. I would say that it only works if you use it inside ui:define. Nevertheless, I don't think it will solve your problem as it is probably evaluated too late in the lifecycle. What do you want to accomplish with your phase listener? Maybe there is a completely different solution for your problem. regards Michael Am 25.10.2011 um 11:19 schrieb Me Self <wmso...@gmail.com>: > How do I access a managed bean from a phaselistener without it knowing > the faces-config.xml name of the bean? I have 1 phaselistener that > acts across hundreds of pages that each have one managed bean. All the > managed beans subclass the same base class. > > All pages are a composition of the same template and as a parameter > for that template all pages set a <ui:param> with the name > "managedbean" that references the actual bean for that page: > > <ui:composition template="/WEB-INF/template.xhtml"> > <ui:param name="managedbean" value="#{someBean}" /> > <ui:define name="content">... > > From the phaselistener I tried accessing the managed bean through the > param name "managedbean" but that is not accessible (at least not in > the UPDATE_MODEL_VALUES phase): > > @Override > public void afterPhase(PhaseEvent event) { > ... > Base neededBean = (Base) facesContext > > .getApplication().evaluateExpressionGet(facesContext,"#{managedbean}",Base.class); > > > The line above returns null unless I change the EL to refer directly > to a bean name from faces-config.xml. I can't find the "managedbean" > through the external context parameters either. > > I also tried setting "managedbean" in a scope using the Set tag: > > <c:set var="scopedmanagedbean" value="#{managedbean}" scope="request"/> > > But the attribute is not in the request scope when tested from the > phaselistener using: > > HttpServletRequest req = (HttpServletRequest) facesContext > > .getCurrentInstance().getExternalContext().getRequest().getAttributeNames(); > > > Anyone know to get hold of the bean through the ui:param ?