Hi Everyone i am new to jsf, I am trying to use prime faces picklist from (http://www.primefaces.org/showcase/ui/picklist.jsf) The picker is working fine,
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.
I ended up here while searching [a link]JSF ajax commandbutton not updating primefaces picklist
Here's my xhtml code
<p:commandButton value="Ajax Submit" update="@form" id="ajax"
actionListener="#{codetype.PopulateCodes}" styleClass="ui-priority-primary"/>
<p:pickList id="pickList" value="#{pickListBean.cities}" var="city"
itemLabel="#{city}" itemValue="#{city}" />
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
@ManagedBean(name="codetype")
@ViewScoped
public class CodetypeBean implements Serializable {
public CodetypeBean () {
// Cities
List<String> citiesSource = new ArrayList<String>();
List<String> citiesTarget = new ArrayList<String>();
citiesSource.add("Istanbul"); citiesSource.add("Ankara");
citiesSource.add("Izmir"); citiesSource.add("Antalya");
citiesSource.add("Bursa");
cities = new DualListModel<String>(citiesSource, citiesTarget);
}
public void PopulateCodes() {
List <String>changedListSource= new ArrayList<String>();
//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<String>(changedListSource, changedListTarget);
}}