4 Replies Latest reply on Apr 15, 2011 9:50 AM by djnose

    load a complete JSF page with AJAX

    djnose Newbie

      Hi,

       

      i would like to know if it is possible to load a page (like a [code]request.getRequestDispatcher(page).forward(request, response);[/code]) with Richfaces.

      "Oldschool" i would just replace some innerHTML with a simple ajax call.

      But i wonder if there is a "nicer" way to do something similar.

      All i found was "just" to reload some small parts of a page (like a <h:outputText or so)

      But not a complete JSF page with some panels, tables and so on...

      Maybe i am to oldschool

      Thx!

        • 1. load a complete JSF page with AJAX
          Nick Belaevski Master

          Hi,

           

          Point to those components via 'reRender' attribute - that's all you have to do. Components being updated can be arbitrary complex, tables, trees, panels, etc. Also check a4j:include example at livedemo - it shows how to update parts of page using navigation rules (wizard-style pages).

          • 2. load a complete JSF page with AJAX
            djnose Newbie

            thx for your reply, but i dont want to update anything (not right now ) i want to load a page which has not been included,

            which has not been loaded yet and which should also work like every page i may include.

            Lets imagine i have a index page with a menu and a div, where the main-stuff is displayed.

            The menu may have the entries

            Entry1

            entry2

            and so on...

            as far as i know (doing it the oldschool-selfwritten-way) i would create a JS function, create my XMLHTTPObject and send a request to,

            lets say, my ControllerServlet.

            Here i just have to forward my JSF page (do some stuff in js, but lets ignore that for now)

            and finally i would say: document.getElementById(div).innerHTML = respText;

             

            So the page is now loaded and should work.

             

            I tried that with stuff like

            <rich:togglePanel switchType="ajax">

                <rich:togglePanelItem name="wstep1">

                    <ui:include src="/page2.xhtml" />

                </rich:togglePanelItem>

             

            cause <a4j:include isn´t supported anymore.

            But that did not work like expected. (JS didnt work f.e.)

             

            I dont want to do it the old way, cause i dont want to take care about issues like forward / backward in your browser.

            Dont want to load all the JS after my request by my own and so on...

            Maybe i just think to complex and it is very easy dont know .. any example would be appreciate

             

            Thx!

            • 3. load a complete JSF page with AJAX
              Ilya Shaikovsky Master

              <rich:togglePanel switchType="ajax">

                  <rich:togglePanelItem name="wstep1">

                      <ui:include src="/page2.xhtml" />

                  </rich:togglePanelItem>

              But that did not work like expected. (JS didnt work f.e.)

              js of the panel? Then check that you wrapped it in h:form.

              • 4. load a complete JSF page with AJAX
                djnose Newbie

                it finally worked after all...just did it the wrong way.

                Thx for your help!