In Primefaces 4 pickList has transfer event only, the select/unselect events have been added in Primefaces 5.2
From the docs:
Ajax Behavior Events
PickList provides transfer as the default and only ajax behavior event
that is fired when an item is moved from one list to the other.
Example below demonstrates how to use this event.
<p:pickList value="#{pickListBean.cities}" var="city"
itemLabel="#{city}" itemValue="#{city}">
<p:ajax event="transfer" listener="#{pickListBean.handleTransfer}" />
</p:pickList>
public class PickListBean {
//DualListModel code
public void handleTransfer(TransferEvent event) {
//event.getItems() : List of items transferred
//event.isAdd() : Is transfer from source to target
//event.isRemove() : Is transfer from target to source
}
}
UPDATE:
To catch the select/unselect event you can bind to checkboxes click event
<p:pickList widgetVar="pick" showCheckbox="true" id="pickList" value="#{ctrl.elts}" var="elt" itemLabel="#{elt}" itemValue="#{elts}" >
<f:facet name="sourceCaption">A</f:facet>
<f:facet name="targetCaption">B</f:facet>
</p:pickList>
<script>
$(function(){
PF('pick').checkboxes.each(function(){
$(this).bind("click", function(){
var checked = $(this).find("> span.ui-icon-check").length > 0
if ( checked ){
alert('checked');
} else {
alert('unchecked');
}
});
});
});
</script>
Then if you need to call a bean listener you can add two remoteCommands and call the functions in click callback
<p:pickList widgetVar="pick" showCheckbox="true" id="pickList" value="#{ctrl.elts}" var="elt" itemLabel="#{elt}" itemValue="#{elts}" >
<f:facet name="sourceCaption">A</f:facet>
<f:facet name="targetCaption">B</f:facet>
</p:pickList>
<p:remoteCommand name="select" actionListener="#{ctrl.select}" />
<p:remoteCommand name="unselect" actionListener="#{ctrl.onUnselect}" />
<script>
$(function(){
PF('pick').checkboxes.each(function(){
$(this).bind("click", function(){
var checked = $(this).find("> span.ui-icon-check").length > 0
if ( checked ){
select();
} else {
unselect();
}
});
});
});
</script>
Obviously the listener can't accept a SelectEvent/UnselectEvent but with remoteCommand you can pass params if you need:
Pass parameter to p:remoteCommand from JavaScript