Do you have a naming convention for your beans? Can you resolve the name of the 
bean from the name of the view it is used in?

Like: myPage1.xhtml -> MyPage1Bean.java


Am 26.10.2011 um 11:42 schrieb Me Self <wmso...@gmail.com>:

> What Im trying to accomplish is to invoke an init() method on the
> managed bean _after_ construction. This should be possible using
> @PostConstruct with JSF 1.2 running in a JEE5 container. However since
> I have hundreds of managed beans I dont want to add this annotation to
> each and every bean. Some of the logic going on in init() will be
> common to all managed beans so it makes sense to start the init() in
> their common super class. Unfortunately @PostConstruct seems to be
> ignored when I add it to the super class (it works fine on the
> subclass). This may be a bug or it may be the correct spec behaviour -
> Im not sure. Im using MyFaces1.2+Weblogic10.3.
> 
> 
> 
> On Wed, Oct 26, 2011 at 11:15 AM, Michael Kurz <michi.k...@gmx.at> wrote:
>> 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 ?
>> 

Reply via email to