I have SelectManyMenu (primeFaces 6.1) and "Select All" and "Deselect All" buttons, which selects/deselects all items in the selection list.I modified the SelectManyMenu with a filter,but my "Select All" button still relies on the java method for selection, which means all items of the unfiltered (complete) selection list appears selected even user filters the selection list before clicking "Select All".
Is there a way to select all displayed (filtered or unfiltered) items in SelectmanyMenu on client side?
I tried to make a "Select All item on Filtered List" button which is rendered conditionally (if user types into Filter box) but i can't find any events that i can use in order to create a filter-based action.
xhtml File:
<h:panelGroup id="param-type-3-cell-2" layout="block">
<p:selectManyMenu id="selectManyMenu"
rendered="#{parameter.multiValue}"
value="#{parameter.selectionList.selectionLabelListString}"
disabled="#{parameter.ruleParam.option ne 'OPTION_DEFAULT' or parameter.readonly or not parameter.fullyLoaded}"
label="#{parameter.selectedLabel}"
style="width:#{parameter.selectionList.listWidth}px;"
styleClass="sb-input-small" scrollHeight="#{parameter.selectionList.listStyleHeightMaxInt}"
filter="#{parameter.listBoxFilter}" filterMatchMode="#{parameter.listBoxFilterMode}">
<f:selectItems value="#{parameter.selectionList.selectionList}"
var="selitem"
itemValue="#{selitem.label}"
itemLabel="#{selitem.label}" />
<!-- AJAX if this param acts as a trigger for other params -->
<p:ajax event="change"
listener="#{myController.handleParameters(parameter)}"
oncomplete="parameterChangeAction()"
disabled="#{empty parameter.listOfTriggeredParameters}"/>
</p:selectManyMenu>
<h:panelGroup layout="block">
<h:outputText id="numberOfValues"
value="#{msg.param_show_entries} #{parameter.selectionList.numberOfSelectedValues}"
style="#{parameter.readonly or not parameter.fullyLoaded ? 'opacity: 0.3;' : ''}"/>
</h:panelGroup>
<h:panelGroup layout="block" styleClass="paramButtonPanel">
<p:commandButton rendered="#{parameter.multiValue}"
disabled="#{parameter.readonly or not parameter.fullyLoaded}"
styleClass="rich-button-submit inline-block"
value="#{msg.param_button_all}"
oncomplete="parameterChangeAction()"
process="@this"
widgetVar="BtnSaveAll"
id="selectAllBtn"
action="#{parameter.selectionList.selectAll}"
title="#{msg.param_button_allhint}">
<!-- AJAX if this param acts as a trigger for other params -->
<p:ajax event="click"
listener="#{myController.handleParameters(parameter)}"
disabled="#{empty parameter.listOfTriggeredParameters}"/>
</p:commandButton>
<p:commandButton rendered="#{parameter.multiValue}"
disabled="#{parameter.readonly or not parameter.fullyLoaded}"
styleClass="rich-button-submit inline-block"
style="margin-left: 5px;"
value="#{msg.param_button_nothing}"
oncomplete="parameterChangeAction()"
id="deselectAllBtn"
process="@this"
action="#{parameter.selectionList.deselectAll}"
title="#{msg.param_button_nothinghint}">
<p:ajax event="click"
listener="#{myController.handleParameters(parameter)}"
disabled="#{empty parameter.listOfTriggeredParameters}"/>
</p:commandButton>
</h:panelGroup>
</h:panelGroup>
Parameter object:
/**
*
* @return
*/
public BirdSelectionList getSelectionList()
{
return selectionList;
}
/**
*
* @param selectionList
*/
public void setSelectionList(MySelectionList selectionList)
{
this.selectionList = selectionList;
}
MySelectionList object:
public void selectAll()
{
selectionListString = new ArrayList<>();
for (MySelectItem selectItem : selectionList)
{
selectionListString.add(selectItem.getValue());
}
}
public void deselectAll()
{
this.selectionListString = new ArrayList<>();
}
Has anyone an idea how this can be done?
P.S : I use PrimeFaces 6.1