This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSF and the fly likes Pass data between managed/ backing beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Pass data between managed/ backing beans" Watch "Pass data between managed/ backing beans" New topic
Author

Pass data between managed/ backing beans

Anoop V. Kumar
Greenhorn

Joined: Jan 21, 2006
Posts: 18
I have a simple application with 3 pages and there is a backing bean for each page say page1-bb1, page2-bb2 and page3-bb3.

The value selected in page1 by the user is actually the input to displaying results in the page2 and again value from page2 is inout to page3. My question is what is the best way to pass these values/data between page1 and bean2 and page2 and bean3??

Is it really necessary that all managed beans for this application to work are in session scope?

Thanks in advance,
Anoop
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
If you need to pass data from page1 to page2 or page2 to page3 you can use a request scope bean. However if you want to pass data from the page1 to the page3 without using (showing, storing) it on the page2, you have to have the session scope.
take a look at http://jsffaq.com/Wiki.jsp?page=HowToAccessOneManagedBeanFromAnotherManagedBean
for ways how to access one bean from the another one.
I suggest, in your particular case, when each page has the own backing bean, the right way is using the reference bean. Actually, you can access the page1bean from the page2bean because if it is still alive, but this break the architecture idea.

--
Sergey : http://jsfTutorials.net
Anoop V. Kumar
Greenhorn

Joined: Jan 21, 2006
Posts: 18
Thanks a TON Sergey... Phew - I never knew this place existed - it is like a treasure house - I am hoping to implement almost every thing that is discusssed in the faq - Thanks again...

-Anoop
Anoop V. Kumar
Greenhorn

Joined: Jan 21, 2006
Posts: 18
Can you further help me with one thing that I am struggling...

I have a page (call it page1 using the backing bean bb1) where a user selects a value. Now I need to send the user to page2 (using bb2) AND I need to send the value that the user selected to the bb2... how can I do that..

Basically my question now is how do I send data from a jsp page to a backing bean that the jsp page does not use??

Thanks,
Anoop
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass data between managed/ backing beans