myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torin Chichirico" <To...@useful-networks.com>
Subject RE: variable managed bean name in JSF EL
Date Wed, 04 Apr 2007 23:31:45 GMT
Thank you for the responses.  That is exactly what I was asking Simon.
And t:aliasBean seems to have done the trick.  I have not tried Sushma's
solution yet but t:aliasBean is working nicely.  Thanks for the help!

- Torin    

-----Original Message-----
From: Simon Kitching [mailto:simon.kitching@rhe.co.nz] 
Sent: Wednesday, April 04, 2007 5:20 PM
To: MyFaces Discussion
Cc: Torin Chichirico
Subject: Re: variable managed bean name in JSF EL

I think that what Torin was really asking was how to make
<managedBeanName> reference different objects depending on what "parent"

page included this one.

When using JSP, the tomahawk t:aliasBean tag is the best way to do this:

page1:
   <t:aliasBean value="#{realBean1}" alias="#{dst}">
     <jsp:include ..../>
   </t:aliasBean>

page2:
   <t:aliasBean value="#{realBean2}" alias="#{dst}">
     <jsp:include ..../>
   </t:aliasBean>

The included page can then reference #{dst}. The effect is pretty much
like a method parameter.

Regards,

Simon

sushma sharma wrote:
>   you can do this
> 
> <h:graphicImage id="image" 
> url="#{requestScope[<managedBeanName>].image}" />
> 
> 
> On Thu, 05 Apr 2007 Torin Chichirico wrote :
>  >I'm still kind of new to JSF, so this may be more of a general JSF  
> >question, but I'm wondering if there's any way in JSF or MyFaces to 
> do  >the following:
>  >
>  >I have a JSF page that I want to include in multiple other JSF pages

> and  >I need to pass a value containing the name of a managed bean 
> from the  >parent page to the included JSF page.  Then in the included

> page I want  >to use the value managed bean name variable in JSF 
> expressions.  So the  >included JSF page would look something like
this...
>  >
>  >
>  ><% String managedBeanName =
>  >(String)request.getAttribute("managedBeanName");%>
>  >
>  >....
>  >
>  ><h:graphicImage id="image" url="#{<managedBeanName>.image}" />  >
 >

> >  >Is there a way to substitute my variable in the JSF expression and

> have  >it call the method on the correct bean?  Or is there a better 
> way to do  >what I'm trying to do here?  Unfortunately we're still 
> using JSP as our  >view.... haven't converted to facelets yet.  Any 
> help is appreciated.
>  >Thanks,
>  >
>  >- Torin

Mime
View raw message