voyent
Send parameters between managed beans  XML
Forum Index -> General Help
Author Message
mdoval

Joined: 04/Apr/2009 00:00:00
Messages: 5
Offline


Hey guys, my question is this, there is the possibility of sending parameters between "Managed Beans"

For example.
I have a project with two pages Page1 and Page2 with their Bean1 and Bean2 Managed Beans.

I need the user takes some action on page1 which is managed by the Bean1 and this sends a parameter to Bean2 for then to redirect to Page2 and this shows the parameter sent from Bean1 to Bean2.

Because When I tried to Put Bean2 as a property in Bean1 (and both in request scope) whien I send a parameter and go to Page2 the Bean2 is not the same object than property in Bean1 and the parameter is Null, because Bean2 change.

I tried to do this, Putting Bean2 as property of Bean1, and Bean2 in the scope Session, but I don't know if this is a good practice.

Do you have any idea?

Martin
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


So, when you navigate to pagee 2, you have 2 possibilities:
1. Simple navigation (no redirect) and then you can just put the values as request attributes and get them back in the second bean
2. Navigation with redirect (this is a real browser redirect) so if the beans have some "request" scope, the second bean will always be recreated. There is nothing in between but the session (If you're using icefaces 2.0 you should be able to use the "flash" scope, but you didn't mention the version). So you would have to put the parameters on the session, and remove them in the second bean.
3. Basically it's best to keep your controller beans uncoupled as much as possible so don't inject one into another. One bean should put some parameters on the session and signal redirect, then the second bean (whichever it may be) should get the parameters from the session (and remove them) and deal with them.

Cheers,

Eduard Korenschi
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team