[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.webtools.jsf] Re: Loop through the Mbeans in Session Scope

On 3/5/2008 4:59 AM, Wolfgang Knauf wrote:
> Hi Reto,
> 
> you can find the MBeans in the session context, where the key is the MBean name 
> from faces-config.xml:

Yes, but OP said he didn't know the names of the beans.

> HttpSession session = (HttpSession) 
> FacesContext.getCurrentInstance().getExternalContext().getSession(false);
> session.getAttribute ("myManagedBeanName")

This could thrown an NPE if getSession(false) didn't return a session.

A better way to access a managed bean (knowing its name) is to use JSF API
for ValueBindings (JSF 1.1) or ValueExpressions (JSF 1.2).

> But I am not sure whether all registered MBeans with session scope are created 
> at e.g. session start.

None of them are created at session start. Managed beans are created when they
are first referenced in an expression.

> 
> Best regards
> 
> Wolfgang
> 
> Reto Huber schrieb:
>> Hi
>>
>> I would like to loop through all registred MBeans (in session scope) in the 
>> current session. Is there an easy way to do this? I don't have the name of 
>> each Mbean to call them.
>>
>> Regards,
>> Reto 
>>
>>