0 Replies Latest reply on Jul 10, 2013 11:25 AM by lionceau

    How i can use  a List in rich:listShuttle ???

    lionceau

      Hello,

      I use Eclipse, JSF 1.2 and Richfaces 3.3.3. and  tomcat 6


      I would like to use rich:listShuttle , but I can't use a List in my ListShuttle.


      In my gestion-profils.xhtml I have this :

       

      <rich:listShuttle  sourceValue="#{pickBean.sourceList}"
                                targetValue="#{pickBean.listValues}" var="items"  converter="convertString"
                                 sourceCaptionLabel="Droits disponibles" targetCaptionLabel="Droit selectionné" listWidth="165px" 
                                 listHeight="100px" orderable="true" orderControlsVisible="false" fastOrderControlsVisible="false">
                                 <h:outputText value="#{items}"/>
       </rich:listShuttle >
      
      

      I use init() in pickbean.java to make my List

       

      import java.util.ArrayList;
      import java.util.List;
      import javax.annotation.PostConstruct;
      import javax.faces.model.SelectItem;
      
      
      /**
       * 
       * 
       */
      public class PickBean {
       /* Variable pour le formulaire pour la gestion des droits du profil*/
      
       private List<String> listValues;
       private List<String> sourceList;
      
      //     public List<SelectItem> getListeDroitsDisponibles () {
      //          List<SelectItem> liste = new ArrayList<SelectItem>();
      //          liste.add(new SelectItem(sourceList.get(index), label))
      //     }
      
      
      
       /* #################### INIT #################### */
          /**
           * Méthode permettant d'initialieser les champs du formulaire
           * Pour info , l'annotation PostConstruct sert a preciser que cette fonction doit etre executer juste après le constructeur
           */
       @PostConstruct
       public void init() {
      
       // creation du nouveau formulaire
             // List<SelectItem> list = new ArrayList<SelectItem>();
       //PickBean nouveauFormulaire = null;
       System.out.println("taille sourceList : " + sourceList.size());
       sourceList.add("key1");
       sourceList.add("key2");
       sourceList.add("key3");
      
       System.out.println("Je suis passé par là...");
       System.out.println("1ère string : " + sourceList.get(0));
       System.out.println("taille sourceList : " + sourceList.size());
      
       //ajout des champs dans le formulaire
       /*if (nouveauFormulaire.sourceList == null) {                     
       nouveauFormulaire.sourceList.add(new SelectItem("key1", "Utilisateur"));
       nouveauFormulaire.sourceList.add(new SelectItem("key2", "Validateur"));
       nouveauFormulaire.sourceList.add(new SelectItem("key3", "Gestionaire"));
       nouveauFormulaire.sourceList.add(new SelectItem("key4", "Administrateur"));
       nouveauFormulaire.sourceList.add(new SelectItem("key5", "Super Administrateur"));
       }     */ 
       }
      
       /* #################### listValues #################### */
          /**
           * Méthode permettant d'afficher la liste des champs pour le formulaire
           * à la création du bean.
           * 
           * @return listValues
           */
       public List<String> getListValues() {
      //          listValues.add(new SelectItem("csd", "csdvgfb"));
       return listValues;
       }
       public void setListValues(List<String> listval) {
       listValues = listval;
       }
       /* #################### sourceList #################### */
          /**
           * Méthode permettant d'afficher la liste des champs de réponse pour le formulaire
           *  
           *  @return sourceList
           */
       public List<String> getSourceList() {
      
       return sourceList;
       }
       public void setSourceList(List<String> srcList) {
       sourceList = srcList;
       }
      }
      
      

       

       

       

       

       

      module-administration.xml

       

       

      <?xml version="1.0" encoding="UTF-8"?>
      
      <faces-config
          xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
          version="1.2">
      
          <!-- ==================== MANAGED-BEANS ==================== -->
       <managed-bean>
       <description>
       Ce bean est utilisé pour la classe PickBean, ce bean nous sert pour la gestion des droits. 
       </description>
       <managed-bean-name>pickBean</managed-bean-name>
       <managed-bean-class>com.applications.gestioncs.administration.PickBean</managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       <managed-property>
       <property-name>listValues</property-name>
       <property-class>java.util.ArrayList</property-class>
       <list-entries>
       <value-class>java.lang.String</value-class>
       </list-entries>
       </managed-property>
       <managed-property>
       <property-name>sourceList</property-name>
       <property-class>java.util.ArrayList</property-class>
       <list-entries>
       <value-class>java.lang.String</value-class>
       </list-entries>
       </managed-property>
       </managed-bean>
      
          <!-- ==================== CONVERTERS ==================== -->
          <converter>
      <!--         <converter-for-class>java.lang.String</converter-for-class>-->
       <converter-id>convertString</converter-id>
       <converter-class>com.applications.gestioncs.administration.StringConverter</converter-class>
      <!--            <description>Permet de convertir un objet String en String (Utile pour les composants Richfaces)</description>-->
      
      
          </converter>
      
      
       <!-- ==================== NAVIGATION RULES ==================== -->
      
       <!-- ========== FROM : module conges ========== -->
       <navigation-rule>
      <!--          <description>Règles de navigation à l'intérieur du module de congés</description>
       <from-view-id>/application/conges/*</from-view-id>-->
       </navigation-rule>
       
       
      </faces-config>
      
      

       

      stringconverter.java

       


      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.Converter;
      
      /**
       * 
       *
       */
      public class StringConverter implements Converter {
      
       /**
       * {@inheritDoc}
       *
       * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
       */
       @Override
       public Object getAsObject(FacesContext context, UIComponent component,
       String value) {
       System.out.println("getAsObject : " + value);
       return value;
       }
      
       /**
       * {@inheritDoc}
       *
       * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
       */
       @Override
       public String getAsString(FacesContext context, UIComponent component,
       Object value) {
       System.out.println("getAsString :" + value);
       return (String) value;
       }
      
      }
      
      

       

       

       

       

       


      Thank you for your help.


       

       

      Florian,