1 Reply Latest reply on Mar 31, 2009 2:02 PM by jbalunas

    select list updating on every call

      Look at the following code:

      public class User {
       private String name;
       private List<SelectItem> temp_list;
      
      ...setter, getter
      
       public User() {
       if(this.getName() == null) {
       this.populate();
       }
       }
       public void populate() {
       temp_list = new ArrayList<SelectItem>();
       temp_list.add(new SelectItem("Sunday"));
       temp_list.add(new SelectItem("Monday"));
       temp_list.add(new SelectItem("Tuesday"));
       }
      


      <a4j:region selfRendered="true" id="text">
       <h:selectOneMenu id="symbol" value="#{user.name}">
       <f:selectItems value="#{user.temp_list}" />
       </h:selectOneMenu>
       <a4j:commandButton action="#{user.getData}" value="Get"/>
      </a4j:region>
      


      Now whenever i press the button, populate() call again and list is populated with all three values again. I want to put the restriction that populate() should be call only once when the page loads.
      Any suggestions.