4 Replies Latest reply on Jul 11, 2007 4:14 PM by Sergey Smirnov

    Rerender not reflecting change in bean

    Scott Guilbeaux Newbie

      I have a select one menu that when a certain selection is made it makes a change in the bean and rerenders a group of check boxes. This code worked in an older 1.1.1 snapshot, but with the official 1.1.1 release and 1.1.2 snapshots it does not.

      The debug dialog shows that it does rerender the boxePanel but none of the boxes become checked.

      The xhtml code is as follows

      
      <!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:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a="https://ajax4jsf.dev.java.net/ajax"
       xmlns:r="http://richfaces.ajax4jsf.org/rich"
       xmlns:h="http://java.sun.com/jsf/html">
      
       <body>
      
       <h:form id="testForm">
      
       <a:log level="ALL" hotkey="M"/>
      
       <div class="entry">
       <div class="label"><h:outputLabel for="menu">Menu</h:outputLabel></div>
       <div class="input">
       <h:selectOneListbox id="menu" value="#{testBean.menuSelection}" size="5">
       <a:support event="onchange" actionListener="#{testBean.checkMenuSelection}" reRender="boxesPanel" ajaxSingle="true"/>
       <s:selectItems value="#{testBean.menuItems}" var="item" label="#{item}"/>
       </h:selectOneListbox>
       <a:status>
       <f:facet name="start">
       <h:graphicImage value="/images/spinner.gif"/>
       </f:facet>
       </a:status>
       <a:outputPanel ajaxRendered="true">
       <h:message for="menu" styleClass="error"/>
       </a:outputPanel>
       </div>
       </div>
      
       <p/>
      
       <h2>Boxes</h2>
      
       <a:outputPanel id="boxesPanel">
      
       <div class="entry">
       <h:selectManyCheckbox id="boxes" value="#{testBean.selectedBoxes}" layout="pageDirection">
       <s:selectItems value="#{testBean.boxes}" var="box" label="#{box}"/>
       </h:selectManyCheckbox>
       </div>
      
       </a:outputPanel>
      
       </h:form>
      
       </body>
      
      </html>
      
      


      Then bean code is as follows

      
      package com.hochheim.testing;
      
      import java.util.ArrayList;
      import java.util.List;
      import javax.ejb.Stateless;
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      import org.jboss.seam.log.Log;
      
      @Stateless
      @Name("testBean")
      @Scope(ScopeType.SESSION)
      public class TestBean implements Test {
      
       private List<String> menuItems;
       private List<String> boxes;
       private List<String> selectedBoxes;
       private String menuSelection;
       @Logger private static Log log;
      
       public TestBean() {
       menuItems = new ArrayList<String>();
       menuItems.add("Item 1");
       menuItems.add("Item 2");
       menuItems.add("Item 3");
      
       boxes = new ArrayList<String>();
       boxes.add("Box 1");
       boxes.add("Box 2");
       boxes.add("Box 3");
       boxes.add("Box 4");
       }
      
       public List<String> getMenuItems() {
       return menuItems;
       }
      
       public List<String> getBoxes() {
       return boxes;
       }
      
       public List<String> getSelectedBoxes() {
       return selectedBoxes;
       }
      
       public void setSelectedBoxes(List<String> selectedBoxes) {
       this.selectedBoxes = selectedBoxes;
       }
      
       public String getMenuSelection() {
       return menuSelection;
       }
      
       public void setMenuSelection(String menuSelection) {
       this.menuSelection = menuSelection;
       }
      
       public void checkMenuSelection() {
       log.info("Checking menu selection...");
       if(menuSelection.equals("Item 2")) {
       selectBoxes();
       }
       }
      
       private void selectBoxes() {
       log.info("Selecting boxes");
       selectedBoxes = new ArrayList<String>();
       selectedBoxes.add("Box 2");
       selectedBoxes.add("Box 3");
       }
      
      }
      
      


      Thank you for your time.