3 Replies Latest reply on Oct 1, 2009 12:12 PM by igor regis

    100% Ajax Application

    igor regis Newbie

      Hi, this is my first participation here at this forum, I'm build applications with Richfaces/A4J/Seam/Facelets since December/2008 and we are trying to define a unified web application platform for all WEB "channels" (that's how we call the ways we interact with customers i.e: Mobile, Internet for Final users and others corporations, Intranet) we have at the corporation I work.

      I have managed to build a 100% Ajax web app with Richfaces/A4J, of course there are some difficulties, like the fact the some features that you could have on using Seam pages (execute action, page params, ...) they gone away, due to the way the A4J filter was "inserted" into the chain.

      I have a colleague working on this issue to perhaps submit a patch :-)

      And some complex richfaces components like Google Maps integration and some JQuery mask plugins (ok that's not richfaces) just DON'T work when you add them dynamically with AJAX, so you need to do a page reload....

      Anyway, all other features are working well, and I have a fast Web Application, even with some fancy effects, since all navigation occurs through DOM manipulation (Thanks to A4J).

      BUT, I need to do some kind of breadcrumb, so now I've got a problem, because I just don't get out of index page, my viewRoot is always index, I register the navigation that is activated through the application menu (it uses a4j:include with a bean pointing to the page), however after that the pages navigations occurs as any JSF navigation flowing the navigation pages rules, defined on .page.xml that I have defined for each view, then I just miss the current page and I don't now how to listen for this kind of "event". I tried a Phase listener, but as I said the viewRoot is always "index" and I don't know where to get the current view that is rendered by A4J.

      Someone have any clue?

      Regards,
      Igor Regis

        • 1. Re: 100% Ajax Application
          Viacheslav Garmash Newbie

          If I understand correctly what you just described then I think you need your own custom page state tracker exactly because "all navigation occurs through DOM manipulation (Thanks to A4J)".
          If you are still using navigation rules some how (in other words you have several xhtml pages in your app) then you defenitely can identify target view. I think you can do it if you extend current ViewHandler you are using (I assume it is org.ajax4jsf.application.AjaxViewHandler) and override some methods in there. I would recommend to study source of org.ajax4jsf.application.AjaxViewHandler since it is key element in A4J page rendering.

          But if you have only 1 physical page and all page refreshes happened by calling actionListeners then you'll defenitely need some kind of tracking bean (session scope) with java.util.Stack inside that will keep "bread crumbs" for you. So you will need to manually add/remove items to your stack while you are doing some actions in the app.

          • 2. Re: 100% Ajax Application
            Alexander Smirnov Master

            You can bind 'src' attribute of the <a4j:include > component to the bean property, so you can always get current page from that property.
            What is a problem do you have with RichFaces filter ? Seam Filter integrates RichFaces filter since 2.0 release, and they should work together without conflicts.

            • 3. Re: 100% Ajax Application
              igor regis Newbie

               

              "alexsmirnov" wrote:
              You can bind 'src' attribute of the <a4j:include > component to the bean property, so you can always get current page from that property.


              Really thank you for this tip, it's so obvious that I haven't though about that option. So I don't need to do any other filtering to intercept page navigation.

              "alexsmirnov" wrote:

              What is a problem do you have with RichFaces filter ? Seam Filter integrates RichFaces filter since 2.0 release, and they should work together without conflicts.


              I will explain:
              The features like the property login-required for the tag PAGE, the tags , and others are not interpreted when I navigate through pages using ajax.

              Use case:

              I have the index page that include (a4j:include) a PersonList.xhtml, then I click in one person on that list to navigate to PersonDetail.xhtml, I have defined an action to be executed when the PersonDetail.xhtml is requested, but this action is never executed, it is executed only if I do a direct request for that page or a redirect.

              I tested this again, before post this affirmation.

              Since every request have the viewRoot pointing to index.xhtml, Seam filter interpret this action only for index.xhtml and not for PersonDetail.xhtml, the funny thing is that the index action is executed for all pages requests :-)

              If you prefer I can send you a piece of code to demonstrate that, but it's simple to reproduce.

              As I mentioned, I have a colleague looking for this problem, so I don't have details, he says that it looks like to be happening because the A4J filter bypass the Seam filter in one of the JSF phases. But I will have more detail when I talk with him (I'm on vacations now :-)

              There are other limitations too, like the exception treatment tag for pages.xml, it accept only redirect's, so I can't render a error page using the A4J. So my choice was to do the redirect back to the index and change the page included there to the "error.xhtml".

              Example.:
              <exception class="javax.el.ELException">
               <end-conversation/>
               <redirect view-id="/index.xhtml">
               <message for="exceptionHadler" severity="error">Error</message>
               </redirect>
              </exception>
              

              I should have the option to place a render tag there:
              <exception class="javax.el.ELException">
               <end-conversation/>
               <render view-id="/error.xhtml">
               <message for="exceptionHadler" severity="error">Error</message>
               </redirect>
              </exception>
              

              I want to discuss this matter with more details, we can do this in this thread, but in 15 hours I will be traveling, and I will be back on 07/Oct.

              Thank you for you reply!