1 Reply Latest reply on Oct 16, 2014 6:11 AM by Michal Petrov

    RF 4.5 CR1 - PickList onadditems/onremoveitems keep the previous value when submitting

    Franck Gasparotto Newbie


      I want to update dynamically a part of my page that take account of the selected values of a pickList.

      Thus I am using a function plugged to @onadditems and @onremoveitems attributes.

      When the function is called, the selected values of the pickList contains the previous selected values.

      Is it the good to perform what I want to do ?

      Here is a simple example to reproduce the issue


      <h:form id="frm">
        <a4j:jsFunction name="processPickList" execute="pick" />
        <rich:pickList id="pick"
             sourceCaption="Available Numbers" 
             targetCaption="Selected Ones"
             value="#{pickListBean.selectedNumbers}" >
             <f:selectItems value="#{pickListBean.availableNumbers}" var="num" itemValue="#{num}" itemLabel="#{num}"/>
        <a4j:outputPanel id="autoRendered" ajaxRendered="true">
             <rich:dataTable value="#{pickListBean.selectedNumbers}" var="n" noDataLabel="NoSelection" >
                  <rich:column >
                       <f:facet name="header">Selected Numbers</f:facet>
                       <h:outputText value="#{n}" />


      package fr.alladin.common.web.bean.module.test;
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.List;
      import javax.faces.bean.ManagedBean;
      public class PickListBean {
        public List<Integer> availableNumbers = new ArrayList<Integer>();
        public List<Integer> selectedNumbers = new ArrayList<Integer>();
        public PickListBean() {
        public List<Integer> getAvailableNumbers() {
             if (availableNumbers.isEmpty()) {
                  availableNumbers.addAll(Arrays.asList(new Integer[] { 1, 2, 3, 4, 5 }));
             return availableNumbers;
        public void setAvailableNumbers(List<Integer> availableNumbers) {
             this.availableNumbers = availableNumbers;
        public List<Integer> getSelectedNumbers() {
             return selectedNumbers;
        public void setSelectedNumbers(List<Integer> selectedNumbers) {
             this.selectedNumbers = selectedNumbers;