I'm very new to JSF!
I'm using a PrimeFaces selectOneMenu and spent several hours reading questions trying to figure out why either (1) the ajax listener wasn't getting called or (2) why the selectedCategory wasn't updated. Now it works, but I had to change the type getting passed to my bean in value="#{categoryList.selectedCategory}"
to a String
. Before I was using a Category
object. Why is that? Category
does implement java.io.Serializable
if that's important.
Here is my code:
<p:selectOneMenu id="ddlCategories" value="#{categoryList.selectedCategory}"
style="width:125px">
<p:ajax event="change" update="artistGrid" immediate="true"
listener="#{UFOUser.showArtists()}" />
<f:selectItem itemLabel="All Categories" itemValue="null" />
<f:selectItems value="#{categoryList.categories}" var="category"
itemLabel="#{category.name} (#{category.abbreviation})"
itemValue="#{category.getID()}" />
</p:selectOneMenu>