0 Replies Latest reply on Dec 22, 2008 4:32 AM by teamjava

    problem using c:foreach/ui:repeat with richfaces and facelet

    teamjava

      This has puzzled us for some time now. We're currently developing a webapplication using:

      Richfaces 3.2.1
      Facelets 1.1.14
      And JSF 1.2

      Background:
      A big part in the decision to use richfaces was that we needed a Ajax framework for performance issues. The pages we're building is made up by several calls to different backingbeans and if we could just update the Ajax component without calling the rest of the backingbeans outside of this component this would be a major performance advantage for us.

      Problem:
      If we're using c:foreach (or ui:repeat for that matter) as described below the ajax functionality is set aside leaving us with the problem that all backingbeans that exist in the request scope gets instantiated once again.

      Another strange thing (to us) is that the System.out calls in the construct of bbean1 indicates that the call to bbean1 comes before the call to bbean2 (i.e bbean1 construct is run before bbean2) when changing tabs in the richfaces component.

      some facelets view

      ...
      ...
      
       <rich:tabPanel switchType="ajax">
       <rich:tab label="#{bbean2.bar}">
       #{bbean2.bar}
       </rich:tab>
       <rich:tab label="Second" disabled="true">
       Here is tab #2
       </rich:tab>
       <c:forEach items="#{bbean2.lista}" var="el">
       <rich:tab label="#{el}">
       #{el}
       </rich:tab>
       </c:forEach>
       </rich:tabPanel>
      
       <h3>#{bbean1.foo}</h3>
       <ui:repeat value="#{bbean1.fooList}" var="s">
       #{s}
       </ui:repeat>
      ...
      ...
      


      bbean1 (bbean2 looks kind of the same)
      
      import java.util.ArrayList;
      
      /*
       * To change this template, choose Tools | Templates
       * and open the template in the editor.
       */
      import java.util.List;
      
      /**
       *
       */
      public class Bbean1 {
       private String foo ="Katt";
       private List<String> fooList = new ArrayList<String>();
      
       //construct
       public Bbean1() {
       System.out.println("bbean1 is running constructor");
       }
      
       public String getFoo() {
       return foo;
       }
      
       public void setFoo(String foo) {
       this.foo = foo;
       }
      
       public List<String> getFooList() {
       fooList.add("ett");
       fooList.add("två");
       fooList.add("tre");
       fooList.add("fyra");
       return fooList;
       }
      
       public void setFooList(List<String> fooList) {
       this.fooList = fooList;
       }
      }
      



      Question:
      Q1: Is there a way to use c:foreach or ui:repeat with richfaces components in ajax 'mode' without instantiate backingbeans in request scope that lies outside the richfaces component?

      Q2: Why does the backingbeans get instantiated in the wrong order when updating the ajax component?