title: How to update primefaces picklist on certain event like commandbutton click, select box change etc)?
body: <p>Hi Everyone i am new to jsf,
  I am trying to use prime faces picklist
  from  (<a href="http://www.primefaces.org/showcase/ui/picklist.jsf" rel="nofollow noreferrer">http://www.primefaces.org/showcase/ui/picklist.jsf</a>) 
  The picker is working fine,</p>
  
  <p>But when i am trying to populate the sourceList of DualModel based on certain event like commanbutton click ,selectbox change events dynamically ,the picker list is not changing the values. When i debugged the Listener is calling the  correct method and populating the List into cities but in UI the modified list is not showing. Also in the prime faces example there are initializing the cities in the constructor.But i am not doing that.</p>
  
  <p>I ended up here while searching
  [a link]<a href="https://stackoverflow.com/questions/8904202/jsf-ajax-commandbutton-not-updating-primefaces-picklist">JSF ajax commandbutton not updating primefaces picklist</a></p>
  
  <pre><code>               Here's my xhtml code
         &lt;p:commandButton value="Ajax Submit" update="@form" id="ajax"  
         actionListener="#{codetype.PopulateCodes}" styleClass="ui-priority-primary"/&gt;  
         &lt;p:pickList id="pickList" value="#{pickListBean.cities}" var="city"
      itemLabel="#{city}" itemValue="#{city}" /&gt;
  </code></pre>
  
  <p>Here instead of @form i tried the id of piclist like pickList then also the picklist is not rendering with the modified list
          my bean</p>
  
  <pre><code>      @ManagedBean(name="codetype")
        @ViewScoped
        public class CodetypeBean implements Serializable {
         public CodetypeBean () {
  
      // Cities
      List&lt;String&gt; citiesSource = new ArrayList&lt;String&gt;();
      List&lt;String&gt; citiesTarget = new ArrayList&lt;String&gt;();
  
  
          citiesSource.add("Istanbul"); citiesSource.add("Ankara");
       citiesSource.add("Izmir"); citiesSource.add("Antalya");
        citiesSource.add("Bursa");
  
  
      cities = new DualListModel&lt;String&gt;(citiesSource, citiesTarget);
        }
             public void PopulateCodes() {
  
       List &lt;String&gt;changedListSource= new ArrayList&lt;String&gt;();
      //in real time some logic to get the list from db
              //manually adding some list
                      changedListSource.add("PRO-1");
          changedListSource.add("PRO-2");
          changedListSource.add("PRO-3");
          cities = new DualListModel&lt;String&gt;(changedListSource, changedListTarget);
  
      }}
  </code></pre>