File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Inject SessionScoped Bean in ViewScoped Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Inject SessionScoped Bean in ViewScoped Bean" Watch "Inject SessionScoped Bean in ViewScoped Bean" New topic
Author

Inject SessionScoped Bean in ViewScoped Bean

Florian Huber
Greenhorn

Joined: Jun 30, 2011
Posts: 8
Hi

I have a problem Injecting a Session Bean into a View Bean:
I have 2 portlets and i try to use IPC via IcePush, it worked while the history was a static field in the PushTest Bean, but i want to have it in the Session.

PushTest.java:


PushTestSessionBean.java:


If i add a string to the history list, the new string is contained in the sessionBean, but not in the other (called from the other portlet)... but the beans have the same SessionID.
So, if I inject a SessionBean in a ViewScoped bean and call this viewScopedBean twice from the same session, I expect that they use the same SessionBean.

This is very strange, has anyone an idea how to solve?
Florian Huber
Greenhorn

Joined: Jun 30, 2011
Posts: 8
Ok, I have found out that @SessionScope Beans are stored in different sessions for each portlet, so I tried with @ApplicationScoped but now every user (as expected) gets the same data

How can I store a Bean in PortletSession.APPLICATION_SCOPE? this should solve the problem, because this is a usersession for every portlet in a WAR
If I can't store these Beans in the APPLICATION_SCOPE, I think about a Map of <SessionID, Object> but then i have to implement the Injection mechanism myself :/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inject SessionScoped Bean in ViewScoped Bean