Notify actions (representing views) from a central component
calin74 Jun 6, 2010 4:04 AMHello,
first of all my configuration:
JBoss App-Server: 4.2.3
JBoss-Seam: 2.2.0.GA
Richfaces: 3.3.1.GA
App-Type: WAR-Applikation
I will try to explain what i have and what i want to do. My problem is, i think very specific, and i don't know a way or the best way to solve it.
I have the following components in my app:
------------------------------------------
- A SocketListener component (listen on port 8084) and scope APPLICATION (the seam name is socketManager
).
- A central component class for register (the seam name is centralManager
) a specific action (my register
component). This component is also in scope APPLICATION.
- An action class (the seam name is realManager
), representing variables and methods for a view a user
can work with. The realManager
implements my self written Interface (with method onMessageReveive()).
This action class is scope CONVERSATION.
This the flow of work:
----------------------
1. A user call my web-app and gets the view, where the realManager
is the action behind.
2. On @Create of the action, the realManager
registers himself on the centralManager
(with the Interface
described above).
3. A message receives the socketManager
.
4. The socketManager
call the centralManager
with this message.
5. The centralManager
iterate all the registered actions and call their onMessageReveive() method.
6. The realManager
(implementing the onMessageReveive() method) update some data and update a list on
the view (with ajax). The update of the view is realized with polling every 400 millis to the action to
look for new data (i know, this is maybe dirty).
And here go my questions ;-)
----------------------------
- What's the best way to notify all active actions (representing a view), on new data arrived?
- In my solution i have problems on detecting not active action (e.g. the user closed the browser, the
user navigate away from the page, ...)
- In my solution i have problems when calling the onMessageReveive() method from the central
registerManager
: in the method (i am calling from the registerManager
), there is no
FacesContext.getCurrentInstance()
- In my solution i have problems ReRender parts of the view programmatically from the action in
the onMessageReveive() method. So i implemented the polling. Someone has a solution to achieve this
without polling?
I hope, i explained my requirements and problems, everybody can understand.
Greetings and Thanx for helping
Chris