7 Replies Latest reply on Jan 19, 2009 10:57 AM by Alexey Kakunin

    Can I get richfaces components to act like Igoogle?

    Team Java Newbie

      Ok. This is kind of linked to our other post (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=147714) we think.

      Ok. So we have a lot of richfaces components in a Facelets view. Now because it takes forever (like 5 seconds) to load this page we would like the page to be sent to client before the Richfaces components renders it's data.

      So every Richfaces component should have that famous ajax loading logo and then present it's data when it's done independently. Like igoogle.

      Can this be done using Richfaces?

      Any pointers to code-example or pointers to the Richfaces components to use is very much appreciated.

        • 1. Re: Can I get richfaces components to act like Igoogle?
          Ilya Shaikovsky Master

          no its not possible out of the box.

          • 2. Re: Can I get richfaces components to act like Igoogle?
            Team Java Newbie

            Ok. Are we missing something here. If you can't load regions on pages after page is loaded. And if the entire page (se our previous post) is loaded behind the scene everytime you're performing a ajax request that involves facelets ui:repeat or c:foreach. Is this what you would espect from a ajax framework? Or is it just us?

            This is not working like we thought it would.

            • 3. Re: Can I get richfaces components to act like Igoogle?
              Ilya Shaikovsky Master

              RichFaces is ajax framework built on top of JSF. So page rendered completelly as for standard JSF application and then sent to client.

              Any request sent by ajax controls could be optimized in order to limit JSF tree processing and invokes encoding only for the areas which specified for update. You could read about the optimization attribute in our docs or at demosite.

              • 4. Re: Can I get richfaces components to act like Igoogle?
                Team Java Newbie

                Ok. We have done some more testing on or second problem (when backingbeans get instansiated when they're not needed). But we can't get this right. What are we doing wrong here...

                Here are som code:
                The facelets view
                [CODE]
                <?xml version='1.0' encoding='iso-8859-1' ?>
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html 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:c="http://java.sun.com/jstl/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:t="http://myfaces.apache.org/tomahawk"
                xmlns:rich="http://richfaces.org/rich">
                <ui:composition>
                <a4j:form>
                <a4j:region id="ajabaja" rerender="true">
                <h:panelGroup id="someId1">

                <rich:tabPanel id="tabPanel1" switchType="ajax">
                <c:forEach items="#{bbean1.fooList}" var="el">
                <rich:tab label="#{el}">
                #{el}
                </rich:tab>
                </c:forEach>
                </rich:tabPanel>

                <a4j:status id="pl1" ><!--for="ajabaja">-->
                <f:facet name="start" id="f1">
                <h:graphicImage value="images/ajax-loader1.gif"></h:graphicImage>
                </f:facet>
                </a4j:status>
                </h:panelGroup>
                </a4j:region>



                <a4j:region id="aj" immidiate="true" rendered="true" selfRerendered="true">
                <h:panelGroup id="someId2">
                <rich:tabPanel id="tabPanel" switchType="ajax">
                <rich:tab label="#{bbean2.bar}">
                #{bbean2.bar}
                </rich:tab>
                <rich:tab label="#{bbean2.bar}">
                #{bbean2.bar}
                </rich:tab>
                </rich:tabPanel>


                <a4j:status id="pl2" for="aj">
                <f:facet name="start" id="f2">
                <h:graphicImage value="images/ajax-loader1.gif"></h:graphicImage>
                </f:facet>
                </a4j:status>
                </h:panelGroup>
                </a4j:region>


                <a4j:status id="pl1">
                <f:facet name="start" id="f1">
                <h:graphicImage value="images/ajax-loader.gif"></h:graphicImage>
                </f:facet>
                </a4j:status>
                </a4j:form>


                </ui:composition>

                [/CODE]

                first backingbean
                [CODE]

                import java.util.ArrayList;

                /*
                * To change this template, choose Tools | Templates
                * and open the template in the editor.
                */
                import java.util.List;
                import java.util.logging.Level;
                import java.util.logging.Logger;

                /**
                *
                * @author Joshua
                */
                public class Bbean1 {

                private String foo = "Katt";
                private List fooList = new ArrayList();
                private Boolean test = false;

                //construct
                public Bbean1() {
                System.out.println("bbean1 is running constructor");
                fooList.add("ett");
                fooList.add("två");
                fooList.add("tre");
                fooList.add("fyra");
                }

                public String getFoo() {
                System.out.println("bbean1.foo");
                try {
                Thread.sleep(2000);
                } catch (InterruptedException ex) {
                Logger.getLogger(Bbean2.class.getName()).log(Level.SEVERE, null, ex);
                }
                return foo;
                }

                public void setFoo(String foo) {
                this.foo = foo;
                }

                public List getFooList() {

                System.out.println("bbean1.fooList");
                return fooList;
                }

                public void setFooList(List fooList) {
                this.fooList = fooList;
                }

                public Boolean getTest() {
                return test;
                }

                public void setTest(Boolean test) {
                this.test = test;
                }

                public void setFocus1() {
                System.out.println("bbean1.setFocus1");
                foo = "ETT";
                }
                }

                [/CODE]

                second backingbean
                [CODE]

                import java.util.ArrayList;
                import java.util.List;
                import java.util.logging.Level;
                import java.util.logging.Logger;

                /*
                * To change this template, choose Tools | Templates
                * and open the template in the editor.
                */
                /**
                *
                * @author Joshua
                */
                public class Bbean2 {

                private String bar = "NOLL";
                private List lista;

                public Bbean2() {
                System.out.println("Bbean2 is running constructor");
                lista = new ArrayList();
                lista.add("Tab A");
                lista.add("Tab B");
                lista.add("Tab C");
                }

                public String getBar() {
                System.out.println("bbean2.bar");
                try {
                Thread.sleep(2000);
                } catch (InterruptedException ex) {
                Logger.getLogger(Bbean2.class.getName()).log(Level.SEVERE, null, ex);
                }
                return bar;
                }

                public void setBar(String bar) {
                this.bar = bar;
                }

                public List getLista() {
                System.out.println("bbean2.lista");
                try {
                Thread.sleep(500);
                } catch (InterruptedException ex) {
                Logger.getLogger(Bbean2.class.getName()).log(Level.SEVERE, null, ex);
                }
                return lista;
                }

                public void setLista(List lista) {
                this.lista = lista;
                }

                public void setFocus1() {
                System.out.println("bbean2.setFocus1");
                bar = "ETT";
                }

                public void setFocus2() {
                System.out.println("bbean2.setFocus2");
                bar = "TVÃ…";
                }
                }
                [/CODE]


                Now, the problem is that if we click on any tab in the first rich:tabPanel everything works like expected. But if we klick on a tab on the second rich:tabPanel the backingbean for the first rich:tabPanel is instansiated.

                If we remove the foreach statement everything works (it doesn't work with a ui:repeat or any substitute for c:foreach)

                • 5. Re: Can I get richfaces components to act like Igoogle?
                  Ilya Shaikovsky Master

                  be carefull with the attributes

                  1) selfRerendered="true" should be selfRendered.
                  2) renderer=true should be rendered

                  • 6. Re: Can I get richfaces components to act like Igoogle?
                    Team Java Newbie

                    really embarrassing. That solved the problem with backingbeans geting instantiated when they shouldn't. Many thanks and our apologies!

                    If we just could get the other problem soled to... ;-)

                    If I clearify...

                    What we want is that the rich faces components makes a Ajax call to retrieve data after the page has loaded in the browser. But that is saying the same thing as my first post...

                    You talked about that rich faces is not capable of this "out of the box". Does that means that it can be done?

                    again.. many thanks!

                    • 7. Re: Can I get richfaces components to act like Igoogle?
                      Alexey Kakunin Newbie

                      I think it means you can do something like this (partial loading part of page after page loaded itself) by yourself for specific page and specific parts on it.

                      I'm afraid, there is no any "general" solution to do it with any page and page components on it