3 Replies Latest reply on Mar 13, 2009 8:49 AM by Seref Arikan

    Pulling RichFaces based xhtml from server dynamically?

    Seref Arikan Newbie

      Hi there,
      I have an existing application to which I am adding some Richfaces based xhtml pages. I want to get xhtml content into parts of the page since this is the way the app works at the moment.
      For some reason the standard method for pulling already existing facelets from server is not working fully when I get a facelet that uses Richfaces.
      How can I get richfaces based facelets from server using Ajax and place them in divs in the page? Would Ajax.updater work? Any best practices, known methods?
      Your response would be appreciate a lot (bid bad deadline coming after me...)

      Kind regards

        • 1. Re: Pulling RichFaces based xhtml from server dynamically?
          Ilya Shaikovsky Master

          It different to tell about the problem with description ony.. Provide the code you using for exploration.

          • 3. Re: Pulling RichFaces based xhtml from server dynamically?
            Seref Arikan Newbie

            Hi there,
            You're right, I should have been clearer :) Ok , here comes the details. This is the piece of javascript that gets executed in the application:

            var ajax = new Ajax.Updater(
             contextPath + '/ajax/paneDispatch.jsf',
             { method: 'get',
             evalScripts: true,
             onComplete: function() {newContentArrived( contentName );},
             onFailure: refreshAll,
             parameters: 'element='+contentName+
             '&serialNo='+serialNo +

            This code will get my RichFaces enhanced xhtml from the server. And tracing the traffic with Firebug, I can see that it does so indeed.
            The problem is, RichFaces generates script tags and javascripts which are NOT added to the page. The following is a copy paste from the Prototype library documentation:

            If your server logic returns JavaScript code along with HTML markup, the Ajax.Updater object can evaluate that JavaScript code. To get the object to treat the response as JavaScript, you simply add evalScripts: true; to the list of properties in the last argument of the object constructor. But there's a caveat. Those script blocks will not be added to the page's script. As the option name evalScripts suggests, the scripts will be evaluated.

            Since the Richfaces generated scripts are in the form of script tags and funtion declarations, they are not added to the page, they simply get lost. This stops the widgets from functioning. Basically it takes Javascript from Ajax of Richfaces :)

            I am looking for a way to place this content as if it has been loaded into the page from the beginning, so that a.xhtml and b.xhtml (both including richfaces components) can be placed on the page, ie: as a response to a button click.

            I hope I can explain my problem, and I definetely hope there is a way to do this. Both ends of this is out of my control, an existing app on one hand, and Richfaces on the other..

            Many thanks for your kind reponse