3 Replies Latest reply on Dec 16, 2008 11:38 AM by John Lennon

    Dropdown menu (h:selectOneMenu) cleared when button (h:commandButton) pressed

    John Lennon Newbie

      Hi,


      I've problem - when on my page I click button Search drop down menu is cleared - when I click Search again it gets populated again!


      Action class:


      @Name("search")
      public class SearchAction {
           
           // without @Out annotation
           @Factory("list")
           public Map<String,Integer> getList() {
                System.out.println("In-method getList");
                Map<String,Integer> list = new TreeMap<String,Integer>();
                list.put("one", 1);
                list.put("two", 2);          
                return list;
           }
           public void it(){          
                System.out.println("In-method it");
           }
      }


      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:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:rich="http://richfaces.org/rich"
          template="layout/template.xhtml">
      
      <ui:define name="body">
          <h:form id="search" styleClass="edit">
              <h:selectOneMenu>
               <s:selectItems
                        value="#{list}"/>
              </h:selectOneMenu>
          <h:commandButton id="search"  value="Search" action="#{search.it}"/>
          </h:form>    
      </ui:define>
      </ui:composition>