1 Reply Latest reply on Jun 7, 2010 10:13 AM by Sean Tozer

    Notify actions (representing views) from a central component

    Christoph Stocker Newbie

      Hello,


      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

        • 1. Re: Notify actions (representing views) from a central component
          Sean Tozer Newbie

          That's an interesting app.


          You mention you're using polling, which I assume to mean rich:poll. You could try using rich:push instead, since this is exactly the use case for that component. That would cut down on some of the load on your server, which is never a bad thing. For updating the view, I think you're going to have to use some form of push or pull polling. It's just an artifact of using a web app.


          For detecting passive actions, such as navigating away from the page, you could use the polling method to check whether the expected client has been checking in. That is, if it's supposed to poll every 400 ms, and it hasn't polled for 5 seconds, that client's probably gone one way or another.


          Is there a specific problem you're having? It seems like you have a fairly reasonable solution for a slightly unique situation.