This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pasing values between beans  RSS feed

 
Terry Bailey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi all,

Another newbie question. I have two .jsp files (which we can call jsp1 and jsp2) each has its own backing bean (bean1 and bean2). In jsp1 I have a select one menu which maps to a property in bean 1:

<h:selectOneMenu styleClass="entrada" value ="#{bean1.id_co}">
<f:selectItems value="#{bean1.listCO}" />
</h:selectOneMenu>

When I move to jsp2 I want the value of bean1.id_co to be availabe when bean2 is created (in bean2 creator) so as I can decide what to do based on this value. How would I go about retreiving this value (a property of bean 1) into bean2's constructor?

Thanks in advance
Terry

 
Ilari Moilanen
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not certain if this works with JSF1 but with JSF 2 I have done it this way
so i just use EL to get the other bean.

This of course relies that the two beans coexist at the same time! You can not get the other bean if it does not exist when you try to fetch it. I have used this from request scoped bean while the bean fetched was in session scope so I knew that the bean existed. And I guess if they are both request scoped and the other is created right after the other has stopped processing the other would still exist (?).
 
Terry Bailey
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Ilari,

That works just file. Thanks a lot, a nice elegant solution which I guess I'll be using a lot.

Terry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!