3 Replies Latest reply on Dec 8, 2009 9:27 PM by gzoller.greg.zoller.aviall.com

    Seam Page without RichFaces?

    gzoller.greg.zoller.aviall.com

      I've noticed that the two Richfaces javascript libraries are roughly 1mb downloads.  I have a number of pages in my application that are not as interactive and don't need rich capabilities, so I want to have a lite version of my template and xhtml that don't include the a4j and rich taglibs.


      When I created these lite versions only core jsf and facelet libraries were included, but...I'm still getting the 2 big Richfaces framework libraries sent down to the browser.


      For example, the top part of my lite template file (which is similar to my lite xhtml page file):




      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <f:view xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         contentType="text/html">
      <html>



      I want to use JSF/Facelets on a lite page, but I don't want the Richfaces overhead on these pages.  Is there any way to selectively ignore RF on some pages while allowing it on others?


      Thanks,
      Greg

        • 1. Re: Seam Page without RichFaces?
          kragoth

          This question would probably be better on the Richfaces forum, but....



          Are you sure that you don't have a <ui:include /> that could be importing the Richfaces javascript?

          • 2. Re: Seam Page without RichFaces?
            gzoller.greg.zoller.aviall.com

            Should be good.  See code below.  I'm asking the question on the Seam forum because I suspect part of my answer may be in how RF is configured within Seam.  Does Seam default to passing every request through some kind of RF processor?


            My Page:



            <!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:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="layout/template_lite.xhtml">
            
                <ui:define name="body">          
                    <h1>Welcome to Seam!</h1>
                </ui:define>
            </ui:composition>





            My Template:




            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <f:view xmlns="http://www.w3.org/1999/xhtml"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               contentType="text/html">
            <html>
               <head>
                  <link rel="shortcut icon" href="#{request.contextPath}/favicon.ico"/>
                  <ui:insert name="head"/>
               </head>
               <body>
                  <div class="body">
                     <ui:insert name="body"/>
                  </div>
               </body>
            </html>
            </f:view>






            The two RF files that seem to always be downloaded to the browser (that I don't want) are:
            http://localhost:8080/kranz/a4j/g/3_3_1.GA/org/ajax4jsf/framework.pack.js
            http://localhost:8080/kranz/a4j/g/3_3_1.GA/org/richfaces/ui.pack.js

            • 3. Re: Seam Page without RichFaces?
              gzoller.greg.zoller.aviall.com

              Got it!


              This behavior is due to how Seam configures RF by default.  In web.xml there are two newer parameters (at least they weren't in an older Seam version I'd been using): org.richfaces.LoadStyleStrategy and org.richfaces.LoadScriptStrategy.  In the default seamgen'ed web.xml these are set to ALL, which seems to download the world, whether its needed/wanted or not.  Change these both to DEFAULT and I get the desired behavior.  If not needed the large JS/CSS are not downloaded.


              FYI for anyone else desiring this behavior.
              Greg