title: Primefaces PickList target is empty on ajax transfer listener
body: <p>I have the following <code>p:pickList</code>:</p>
  
  <pre><code>&lt;p:pickList id="activityUser" value="#{activityEntryController.activityUserDualListModel}" var="model" itemLabel="#{model.fullName}"
      itemValue="#{model}" converter="activityUserListConverter" styleClass="activityUser" required="true" showSourceFilter="true"
      showTargetFilter="true" filterMatchMode="contains"&gt;
  
      &lt;f:facet name="sourceCaption"&gt;Available&lt;/f:facet&gt;
      &lt;f:facet name="targetCaption"&gt;Selected&lt;/f:facet&gt;
  
      &lt;p:column style="width: 400px"&gt;
          &lt;h:outputText value="#{model.fullName}" /&gt;
      &lt;/p:column&gt;
  
      &lt;p:ajax event="transfer" listener="#{activityEntryController.sortUsersOnTransfer}" update="activityUser" /&gt;
  &lt;/p:pickList&gt;
  </code></pre>
  
  <p>The <code>value</code> of this <code>p:pickList</code> is a class which extends the <code>DualListModel&lt;T&gt;</code>:</p>
  
  <pre><code>public class ActivityUserDualListModel extends DualListModel&lt;ActivityUserDTO&gt; {
  
      private static final long serialVersionUID = -5369543532197736480L;
  
      public ActivityUserDualListModel() {
          super();
          initModel();
      }
  
      public ActivityUserDualListModel(List&lt;ActivityUserDTO&gt; source, List&lt;ActivityUserDTO&gt; target) {
          super(source, target);
          initModel();
      }
  
      private void initModel() {
          IServiceProvider serviceProvider = (IServiceProvider) ContextLoader.getCurrentWebApplicationContext().getBean(Beans.SERVICE_PROVIDER.getName());
          IUserService userService = serviceProvider.getUserService();
  
          List&lt;ActivityUserDTO&gt; activityUserDTOs = new ArrayList&lt;ActivityUserDTO&gt;();
  
          for(User user : userService.getAllUser()) {
              if(user.isActive()) {
                  activityUserDTOs.add(constructActivityUserDTO(user));
              }
          }
  
          Collections.sort(activityUserDTOs, ComparatorUtils.getActivityUserFullNameComparator());
  
          setSource(activityUserDTOs);
          setTarget(new ArrayList&lt;ActivityUserDTO&gt;());
      }
  
      private ActivityUserDTO constructActivityUserDTO(User user) {
          ActivityUserDTO activityUserDTO = new ActivityUserDTO();
          activityUserDTO.setId(user.getId());
          activityUserDTO.setUsername(user.getUsername());
          activityUserDTO.setFullName(user.getFullName());
  
          return activityUserDTO;
      }
  }
  </code></pre>
  
  <p>I am instantiation the <code>ActivityUserDualListModel</code> from the <code>PostConstruct</code> method of the <code>ActivityEntryController</code> managed bean.</p>
  
  <p>The <code>listener</code> of the <code>p:ajax</code> which fires at the time of event <code>transfer</code> is:</p>
  
  <pre><code>public void sortUsersOnTransfer(TransferEvent event) {      
      List&lt;ActivityUserDTO&gt; source = activityUserDualListModel.getSource();
      List&lt;ActivityUserDTO&gt; target = activityUserDualListModel.getTarget();
      System.out.println("=============================================");
      for(ActivityUserDTO dto : source) {
          System.out.println(dto.getFullName());
      }
      System.out.println("=============================================");
      System.out.println("=============================================");
      for(ActivityUserDTO dto : target) {
          System.out.println(dto.getFullName());
      }
      System.out.println("=============================================");
  
      if(source != null) {
          Collections.sort(source, ComparatorUtils.getActivityUserFullNameComparator());
      }
  
      if(target != null) {
          Collections.sort(target, ComparatorUtils.getActivityUserFullNameComparator());
      }
  }
  </code></pre>
  
  <p>The strange thing is the <code>target</code> list in the above method is empty. I am unable to find what I am missing. Any pointer would be very helpful to me.</p>
  
  <h2>Edit:</h2>
  
  <p>The following class is the converter:</p>
  
  <pre><code>@FacesConverter("activityUserListConverter")
  public class ActivityUserListConverter implements Converter {
  
      @Override
      public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
          if (!(component instanceof PickList)) {
              return null;
          }
  
          if (StringUtils.isBlank(submittedValue)) {
              return null;
          }
  
          @SuppressWarnings("unchecked")
          DualListModel&lt;ActivityUserDTO&gt; pickListModel = (DualListModel&lt;ActivityUserDTO&gt;) ((PickList) component).getValue();
          ActivityUserDTO ret = null;
  
          for (ActivityUserDTO activityUserDTO : pickListModel.getSource()) {
              if (activityUserDTO.getId().equals(Long.parseLong(submittedValue))) {
                  ret = activityUserDTO;
                  break;
              }
          }
  
          if (ret == null) {
              for (ActivityUserDTO activityUserDTO : pickListModel.getTarget()) {
                  if (activityUserDTO.getId().equals(Long.parseLong(submittedValue))) {
                      ret = activityUserDTO;
                      break;
                  }
              }
          }
  
          return ret;
      }
  
      @Override
      public String getAsString(FacesContext context, UIComponent component, Object value) {
          if (value == null || value.equals("")) {
              return "";
          }
  
          if (value instanceof ActivityUserDTO) {
              return String.valueOf(((ActivityUserDTO) value).getId());
          }
  
          return "";
      }
  }
  </code></pre>
  
  <p>Also I have the following <code>p:commandButton</code> for submitting the form. Now the <code>actionListener</code> is not firing, but it fires if I remove the <code>p:pickList</code> form the xhtml.</p>