2 Replies Latest reply on Jul 16, 2009 2:13 PM by Paul Keogh

    Help with listshuttle

    Bryan Enriquez Newbie

      I want to use a listshuttle to display information about users. All works fine, but when I select a user the property targetValue doesn't return the list of values.

      This is the code of my listshuttle:

      <rich:listShuttle sourceValue="#{obtenerContactos.source}"
                     id="listShuttleContactos" var="usuario"
                     sourceCaptionLabel="Contactos Disponibles:"
                     targetCaptionLabel="Contactos Seleccionados:"
                     targetValue="#{obtenerContactos.target}" showButtonLabels="false"
                     fastOrderControlsVisible="false" orderControlsVisible="false"
                     topControlLabel="Primero" copyAllControlLabel="Copiar Todos"
                     copyControlLabel="Copiar" downControlLabel="Bajar"
                     upControlLabel="Subir" removeAllControlLabel="Eliminar Todos"
                     removeControlLabel="Eliminar" bottomControlLabel="&#218;ltimo"

      this is my java class:

      public class obtenerContactosLibretaDirecciones  {

           EntityManager entityManager;
           Nmusuario user;
           private String filtro;
           Nmcontacto nmcontacto;
           Nmusuario nmusuario;

           private List<Nmcontacto> source;
           private List<Nmcontacto> target;

           public void constructor() {
                try {
                     nmusuario = entityManager.find(Nmusuario.class, user.getIdContacto());
                     source = (nmusuario.getNmcontactos() == null) ? new ArrayList<Nmcontacto>(): new ArrayList<Nmcontacto>(nmusuario.getNmcontactos());
                     target = new ArrayList<Nmcontacto>();               
                } catch (Exception e) {
                     // TODO: handle exception

           public List<Nmcontacto> getSource() {
                return source;

           public void setSource(List<Nmcontacto> source) {
                this.source = source;

           public List<Nmcontacto> getTarget() {
                return target;

           public void setTarget(List<Nmcontacto> target) {
                this.target = target;

           public String getFiltro() {
                return filtro;

           public void setFiltro(String filtro) {
                this.filtro = filtro;
           public void cadenaContactos(){
                /*List<String> cadena = new ArrayList<String>();
                for (int i = 0; i < target.size(); i++) {

      and this is my converter class:

      public class contactoConverter implements javax.faces.convert.Converter{

           @In EntityManager entityManager;
           @In FacesMessages facesMessages;
           public Object getAsObject(FacesContext context, UIComponent component, String value)throws ConverterException {
                try {
                     Nmcontacto contacto=(Nmcontacto)entityManager.createQuery("from Nmcontacto m where m.nombre = :valor")
                     .setParameter("valor", value) .getSingleResult();
                     return contacto;
                } catch (Exception e) {
                     return null;

           public String getAsString(FacesContext context, UIComponent component, Object object)throws ConverterException {
                try {
                     if (!(object instanceof Nmcontacto))
                          throw new ConverterException();
                     String res=((Nmcontacto)object).getNombre();
                     return res;
                } catch (Exception e) {
                     return null;

      I would thank that anybody explain me how resolve my problem.