Reputation: 8606
I am using Netbeans 6.9.1. I am using code in which i am simply using selectManyListBox and i want that when user selects all the values then my valueChangeListener is call. Here what i am doing
<h:selectManyListbox id="countryListBox" size="5" value="#{news.saarcCountries}"
onselect="form.submit();" valueChangeListener="#{news.changeAppearOnCountryPage}">
<f:selectItems value="#{news.saarcCountriesMap}"/>
<f:ajax render="countryPageExpiryCalender" />
</h:selectManyListbox>
<p:calendar id="countryPageExpiryCalender" value="#{news.countryPageExpiryDate}"
navigator="true" style="z-index: 1;" locale="en" mode="popup"
pattern="dd/MM/yyyy" showOn="button" readOnlyInputText="true"
disabled="#{!news.appearOnCountryPage}" />
I also tried this, instead of onselect i used onchnage like
onchange="submit()"
Here is my valueChangeListener
@ManagedBean(name = "news")
@ViewScoped
public class News {
private Map<String, String> saarcCountriesMap = new LinkedHashMap<String, String>();
private Set<String> saarcCountries = new TreeSet<String>();
...
public void changeAppearOnCountryPage(ValueChangeEvent vcEvent){
Iterator iter = saarcCountries.iterator();
while(iter.hasNext()) {
String name = (String)iter.next();
System.out.println(name);
}
} //end of changeAppearOnCountryPage
} //end of class News
I want that when user select all the values from the selectmanyListBox, then my valueChangeListener is call, and i check if i have the values in saarcCountries variable, then i set appearOncountryPage = true, so my calender is render. But my valueChangeListener is not calling. What i am doing wrong?
If i choose onselect, then i want to ask one thing this event will trigger whenever i select the value, of after i have selected all the values. I want that when user select all the values then my ValueChangeListener is call and the values that user selected will be in my saarcCountries variable. So i can check the values that user selected.
I think onchange() is not appropriate in my case. Please help. I am stuck because of it:(
Thanks
Upvotes: 0
Views: 3240
Reputation: 37061
try it like this:
<h:selectManyListbox id="countryListBox" size="5" value="#{news.saarcCountries}">
<f:selectItems value="#{news.saarcCountriesMap}"/>
<f:ajax event="change" listener="#{news.changeAppearOnCountryPage}" render="countryPageExpiryCalender"/>
</h:selectManyListbox>
You don't need the form.submit(); since you can use the ajax...
Upvotes: 2