3 Replies Latest reply: Feb 26, 2008 10:36 AM by Pete Muir RSS

    How to get control of JSF during a request

    Mounir Bakkali Newbie

      Hi,


      I'm currently using Seam-2.0.1 to build an application
      that needs to send responses to the user (to the JSF)
      while the request is processing.


      So for example, let's say I call the ExecuteAction.broadcastFile() method....
      I want to be able to send several display messages
      to the JSF BEFORE the request is terminated!


      In this method, for example there is:


      1. sending getting file... message to JSF
      2. get file from server1
      3. sending done message to JSF
      4. sending compressing file... message to JSF
      5. compress file
      6. sending done message to JSF
      7. sending sending file... to JSF
      8. send file to server2
      9. sending done to JSF
      10. sending operation successful to JSF


      I am using AJAX to make the request.


      Anyone has an idea of how to control JSF (like DOM
      with JSP) from a backing bean?


        • 1. Re: How to get control of JSF during a request
          James Kelly Newbie

          I'd suggest you look into something like RichFace's a4j:poll and Seam's asynchronous methods framework to handle long-running operations like this.


          Your async method would update some state in your application (via events or messaging or what not) and your client-side poll would simply query the current state.

          • 2. Re: How to get control of JSF during a request
            Mounir Bakkali Newbie

            Hi James,


            Thank you for your answer!


            Actually I was more looking into calling UI components
            from a backing bean.


            In the old frameworks it was possible to do that by
            getting the HttpServletResponse and writing into it.


            Do you know anything similar with Seam?


            Basically if we can get something like an javax.faces.component.UIComponent then we could modify
            that component in the backing bean.


            I just want to be able to modify a component on the JSF page
            (example: change some text, change some images, etc...)


            Any idea?

            • 3. Re: How to get control of JSF during a request
              Pete Muir Master

              Mounir Bakkali wrote on Feb 22, 2008 02:31 AM:


              Basically if we can get something like an javax.faces.component.UIComponent then we could modify
              that component in the backing bean.

              I just want to be able to modify a component on the JSF page
              (example: change some text, change some images, etc...)

              Any idea?


              Not really how JSF is supposed to work IMO, but you can use the binding attribute on components for this - just bind to an EVENT scoped bean.