4 Replies Latest reply on May 4, 2011 10:00 AM by dragnic

    ui:include - richPanelMenu - a4j - Lifecycle problem

    dragnic Newbie

      Hey dudes,

       

      i researched a lot of articles and posts, but i actually dont get the solution that fits

       

      i am using richfaces 4 with faclets.

       

      i generated a menu with richPanelMenu.. but maybe the code is much more helpfull...

       

       

      <div class='formContainer'>
           <div class='formMenu'>
              <h:form>
                   <rich:panelMenu mode='ajax' groupMode='ajax'
                    itemChangeListener="#{fgr.updateValue}">
                   <c:forEach items='#{fgr.formItems}' var='formItem'>
                        <rich:panelMenuItem label='#{formItem.name}' name='#{formItem.template}' render='formContent' execute='@region'/>
                   </c:forEach>
                   </rich:panelMenu>
               </h:form>                
           </div><!--  .formMenu -->
           <div class='formContent'>
               <a4j:outputPanel id='formContent'>
                   #{fgr.value}
                   <ui:include src="#{fgr.value}" />
               </a4j:outputPanel>
           </div><!--  .formContent -->
      </div><!--  .formContainer -->
      

       

      and the bean i am using

       

      import java.util.LinkedList;
      import java.util.List;
      
      import javax.annotation.PostConstruct;
      import javax.faces.event.FacesEvent;
      import javax.inject.Named;
      import javax.inject.Singleton;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      
      import ******.JsfResource;
      
      import org.richfaces.event.ItemChangeEvent;
      
      @Named
      @Singleton
      public class Fgr {
      
          static final Log      logger = LogFactory.getLog(Fgr.class);
      
          private List<FormItem> formItems;
      
          private String value;
      
          public Fgr() {}
      
          @PostConstruct
          private void postConstruct() {
              formItems = new LinkedList<FormItem>();
          }
      
          public List<FormItem> getFormItems() {
              if(formItems.size() <= 0) {
                  formItems.add(new FormItem("fID1", JsfResource.getJsfResource("portalMain", "formsMenuNewPerson"),       "/views/forms/personForm.xhtml"));
                  formItems.add(new FormItem("fID2", JsfResource.getJsfResource("portalMain", "formsMenuNewOrganisation"), "/views/forms/oragnisationForm.xhtml"));
                  formItems.add(new FormItem("fID3", JsfResource.getJsfResource("portalMain", "formsMenuNewDevice"),       "/views/forms/deviceForm.xhtml"));
              }
      
              return formItems; 
          }
      
          public String getValue() { return value; }
          public void setValue(String value) { this.value = value; }
      
          public void updateValue(ItemChangeEvent event) {
              logger.info("got itemchangedevent");
              setValue(event.getNewItemName());
          }
      
      }
      

       

      my problem now is, that the ui:include always using an old bean value.. so if i click on the fist button, the bean-value is correct but the ui:include shows nothing, if i click second, the ui:include shows the first template and the bean the second value..

       

      i think i have some trouble with the lifecycle but i acutally dont know how the fix it..

       

      any help would be great =)