6 Replies Latest reply on Aug 31, 2006 3:58 AM by Amir Shay

    Partial page rendering

    Amir Shay Newbie

      I was wondering if there is an "easy way" to implement a partial page rendering using Seam. I have a page that is composed of several parts and want each part to be updated separately (when you log in there is no need to reload the upper banner ?). One possible way is to use frames but I understand that it is not recommended and I got some problem trying to implement it with Faceletes. When looking at Seam remoting component it looks that I need to change the code and instead of calling forms in the Seam components I need to implement all the forms as javascript code that calls the Seam components. Is this the right way to do it ?

      Amir

        • 1. Re: Partial page rendering
          Shane Bryzak Master

          It is possible with remoting, but you need to realise that once you start down that path its hard to turn back. I've successfully implemented a fully remoting-based application for my company and I must say that more than anything it reminds me of the way you used to write client-server apps.

          All the code is loaded "up front" and the client is pretty much self-contained, only retrieving the data it needs from the server and rendering the interface itself. It's not difficult to abstract out the interface generation and there's plenty of Javascript libraries (dojo, etc) that might help out in this area.

          What you miss out on with this architecture is the JSF component model, which means you can't use all those nice JSF components. And you also need to have reasonable Javascript skills. What you end up with though is a very responsive application, and with the minimal client-server communication it's great for reducing load on the server.

          • 2. Re: Partial page rendering
            Raja Master

            Facelets are a good approach of doing these sorts of things, but all the fragments will be redrawn for every screen. Its worked well for some simple things I have tried, if you indicate your problems here or in facelets mailing list, someone might be able to help.

            • 3. Re: Partial page rendering
              dudududu Novice

              try to use ajax4jsf , you can rerender regions in your page.

              • 4. Re: Partial page rendering
                Amir Shay Newbie

                I really don?t have a specific technical question but rather looking for the ?right? approach. My requirement is to build a screen composed of several different parts and be able to update each screen part separately ..For example, a screen composed of an upper banner and a login box. When the user login into the system and the request is validated in the server I don?t want the upper banner to be updated from the server as well. Obviously, I want this functionality to work under Seam+Facelete+JSF!
                I understand that Seam doesn?t have a built in solution for this requirement? Does anyone have an experience with other tools that seems to solve the problem such as Ajax4jsf?

                • 5. Re: Partial page rendering
                  dudududu Novice

                  what problems did you encounter while using frames?

                  • 6. Re: Partial page rendering
                    Amir Shay Newbie

                    I am using Facelete thus the template with frames need to look something like that (file name templateTest.xhtml)

                    <!DOCTYPE html PUBLIC
                    "-//W3C//DTD XHTML 1.0 Frameset//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
                    <html>
                    <head>
                     <link rel="stylesheet" type="text/css" href="css/main.css" media="screen" />
                     <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
                     <script type="text/javascript" src="js/common.js"></script>
                    </head>
                    
                    <frameset rows="235px,*" border="0" frameborder="0" framespacing="0">
                    <frame frameborder="0" scrolling="no" noresize="-1" src="frameUp.seam"/>
                    <frame frameborder="0" scrolling="no" noresize="-1" src="frameDown.seam"/>
                    </frameset>
                    
                    </html>
                    


                    In the non frame version I had in the template
                    <ui:insert name="MainContent"/>
                    tags. Becouse of the above structure I need to move it to frameDown.seam file. Now my MainPage.xhtml looks like this

                    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                     xmlns:ui="http://java.sun.com/jsf/facelets"
                     xmlns:h="http://java.sun.com/jsf/html"
                     xmlns:f="http://java.sun.com/jsf/core"
                     xmlns:s="http://jboss.com/products/seam/taglib"
                     template="templateTest.xhtml">
                    
                     <ui:define name="MainContent">
                     Some Text....
                     </ui:define>
                    </ui:composition>
                    


                    The ui:define doesn't insert the "Some Text...." probably because MainContent is defined in frameDown.seam instead in templateTest.xhtml