I have a selectManyCheckbox which have a list of items shown, When ever I select an item I want a callback on my backing bean to be triggered and then get the value of the selected item for doing some filtering with this value. My problem is that I can't get the backing bean method to be executed. Have tried several ways, here's my code
1
<h:form class="block filter image-list-filter">
<div class="title-block"> FILTER </div>
<div class="content">
<ul class="filter-block">
<p:selectManyCheckbox id="vals" layout="grid"
valueChangeListener="#{bean.selectFilter}" onchange="submit();">
<p:ajax event="click" process="@form" update="@all"/>
<f:selectItems value="#{bean.options}" var="filter"
itemValue="#{filter.idFilter}" itemLabel="#{filter.descr}"
itemDescription="#{filter.image}"/>
</p:selectManyCheckbox>
</ul>
</div>
</h:form>
2
<p:selectManyCheckbox id="vals" layout="grid">
<p:ajax event="click" process="@form" update="@all"
listener="#{bean.selectFilter}" />
<f:selectItems value="#{bean.options}" var="filter"
itemValue="#{filter.idFilter}" itemLabel="#{filter.descr}"
itemDescription="#{filter.image}"/>
</p:selectManyCheckbox>
3
<p:selectManyCheckbox id="vals" layout="grid"
valueChangeListener="#{bean.selectFilter}">
<p:ajax event="click" process="@form" update="@all"/>
<f:selectItems value="#{bean.options}" var="filter"
itemValue="#{filter.idFilter}" itemLabel="#{filter.descr}"
itemDescription="#{filter.image}"/>
</p:selectManyCheckbox>
Backing Bean Method
public void selectFilter(ValueChangeEvent dege) {
Object[] selFilters = (Object[]) dege.getNewValue();
if (selFilters.length != 0) {
//Do stuff
}
}
The options attribute is an ArrayList of a particular object that stores the available values. Of course, this attribute has setter & getter. PF version is 5.0
<p:ajax event="change" listener="#{bean.methodXpto}"/>. And in your bean,public void methodXpto(). Check if it will be triggered. Note that you don't need to pass any argument to the function, just call it. Let me know if it works (Remove the ValueChangeListener of your p:selectManyCheckbox ) - Pellizon