5 Replies Latest reply on Feb 16, 2010 1:17 AM by Raj Tiwari

    Seam Ajax Best Practices

    Stacey Vetzal Newbie

      I would like to open some discussion on Seam Ajax Best Practices.

      I've been building web applications with Seam since 2006, I found it a welcome enhancement to JSF. More recently I've been very happy with the RichFaces and Ajax4JSF integration. Our customers are demanding AJAX style UI interaction, and this has been the sanest way we've found to deliver it to them (after some very frustrating experiences with other approaches like ICEfaces).

      However, there is a slight impedance mismatch between Seam pageflows and the one page does everything development style of AJAX.

      For our applications, we've used a focus variable and broken our page into a series of fragments (using ui:include to bring them together) and wrap display elements inside conditionally rendered divs.

      While this has worked out OK for us, there are some issues I'm unhappy about (big component tree, being careful not to refresh elements with rendered attributes, etc).

      How are others handling this? Is there something you think we're missing out on leveraging in the framework?

        • 1. Re: Seam Ajax Best Practices
          Andre Fernando Salvati Novice

          Any thoghts one year later??

          I'm not being able to develop in a one page does everything way because I need a conversation switcher on my application.


          Should I assume Seam conversation switcher is incompatible with AJAX?

          • 2. Re: Seam Ajax Best Practices
            Raj Tiwari Newbie

            I put together an AJAX-heavy app in the one page does everything pattern two years ago. I went with Seam because on a cursory examination of the blogosphere, it seemed like the right thing to do.

            I have, since, come to realize that a lot of independent reviewers on the web simply parrot out the taglines given to them by the framework authors. Just because there is an add-on called ajax4jsf does not really make JSF ajax-friendly. Or just because developers of Seam have chosen to accommodate AJAX in the framework does not imply that this is the best framework for developing AJAX applications.

            I had a mix of DHTML and Flex on the frontned. I got burned with endless issues, not the least of which had to do with JSF (which is an integral part of Seam) that kept getting in the way.

            I recently started working on a new project which is also AJAX-heavy. I realized that once a user signs on, the application state really lives on the client (hence, one page does everything). I went with a set of RESt-ful web services that expose a quasi-stateless (i.e. stateless within the context of an authenticated HTTP session) API to the frontend. Thereafter, I use jQuery's AJAX and Flex's HTTPRequest object to do what I need to do. The server-side is implemented as a simple servlet for perimeter security and an EJB3 business tier.

            This approach has been so painless, I wish I had taken it two years ago instead of fiddling with Seam.

            Seam is born out of solid use cases that the creators of this framework set out to solve. I am sure it is an excellent fit for many situations. However, I don't think AJAX-heavy applications are the right use for Seam.


            • 3. Re: Seam Ajax Best Practices
              Damian Harvey Apprentice

              Don't confuse all-on-one-page with ajax as they're definitely not the same thing. IMO richfaces/ajax4jsf is a nice simple way to bring some ajax to a JSF web app - it's not intended to be a GWT / SOFEA solution.

              It's got issues, but so does everything. At least it allows you to add ajax when and where you want for a minimum of effort.



              • 4. Re: Seam Ajax Best Practices
                Luis Tama Newbie

                Hi all...

                I posted a related topic on the forum asking for information on how to get anchor-based AJAX navigation in Seam. I hope there is an answer.



                • 5. Re: Seam Ajax Best Practices
                  Raj Tiwari Newbie


                  All-on-one-page and AJAX are just convenient labels. None of them are 100% exact. For most web developers, AJAX is the ability to fetch and render a part of a web page independent of the rest without refreshing the entire contents of the page.

                  What we have been referring to as all-on-one page is making full and complete use of AJAX capability. In this use case, only a skeleton of the page is initially fetched from the server. All further UI changes happen via AJAX. So, while you are right that all-in-one and AJAX are not the same thing, it must be emphasized that this type of UI experience is completely dependent on AJAX. It is not possible without AJAX.

                  When writing such an app, if you are saddled with a framework where AJAX is added as an afterthought, you are in for a lot of unintended masochism.

                  I am sure there is a preponderance of applications which are not all AJAX. For those applications, I am sure Seam is a beautiful match made in heaven. However, if you are making an application that behaves like Google Maps or (the new) Yahoo Mail, I would steer clear of JSF and consequently Seam.


                  PS: If you have to do any serious amount of data transfer in your application, I would also advise reconsidering rich faces. In my previous application I found rich faces adding a filter to the JSF chain that was seriously degrading performance. It was attempting to tweak responses even when it was not involved.

                  If you need good looking UI widgets a la Flex, check out jQueryUI.