4 Replies Latest reply on Mar 7, 2012 3:19 AM by Piotr Czekaj

    RF 4.2 - pickList doesn't use value attribute

    Piotr Czekaj Newbie

      I'm in the middle of migrating application from RF 3 (JBoss 4.2.3) to RF 4.2.0.Final (JBoss 7.1.0). In RF 3.3 I'm using rich:listShuttle component which is missing from RF 4.2 but rich:pickList seems to be it's replacement. Similiar like in Showcase application I'm passing two collections to pickList: one via value attribute, another one via f:selectItems. My problem is that even if I will pass non empty collection to value attribute nothing is displayed on the right (elements passed by f:selectItems are corectly displayed on the left, if I will swap collection passed via value with the one passed via selectItems other collection is visible on the left so I'm sure I didn't pass empty collection). I'm not sure if it's feature or bug, in case if it's a bug below is a way how to reproduce it it in final versions of JBoss 7.0.2 or JBoss 7.1.0.


      Download showcase application tagged for release 4.2.0. Add to class org.richfaces.demo.lists.ListSelectBean following code:


          public void init() {
              selectedCapitals = new ArrayList<Capital>();
              Capital c = new Capital();


      To see error open web browser and navigate to component pickList sample (http://localhost:8080/showcase/richfaces/component-sample.jsf?demo=pickList), for me expected behaviour would be to see Montgomery2 on the right part of pickList component but it will be empty.

        • 1. Re: RF 4.2 - pickList doesn't use value attribute
          iabughosh Master

          hello Piotr,

          relax Piotr, it is not a bug , I'll explain in details :

          if you have this .xhtml code:


          <rich:pickList id="yourList"




            <f:selectItems value="#{yourBean.availableItems}"






          then the value attribute in the rich:pickList needs to be a collection of primitive type or String (ex:List<String>, List<Integer>), and itemValue attr at f:selectItems needs to be of a type String, int (as pickList value type).


          RichFaces show case was able to set List<CustomObjects> in the value attribute because they were using FacesConverter named "CapitalsConverter".



          • 2. Re: RF 4.2 - pickList doesn't use value attribute
            Piotr Czekaj Newbie

            Thanks for response but even for strings pickList doesn't work as I would expect. Below image shows how page looks like in browser when first loaded, looking at init method it should show "Item 4" and "Item 5" on the right.




            Bean code:


            package example;
            import java.io.Serializable;
            import java.util.ArrayList;
            import java.util.List;
            import javax.annotation.PostConstruct;
            import javax.ejb.Stateful;
            import javax.enterprise.context.SessionScoped;
            import javax.inject.Named;
            public class PickList implements Serializable {
                      private List<String> freeItems = new ArrayList<String>();
                      private List<String> selectedItems = new ArrayList<String>();
                      public void init() {
                                freeItems.add("Item 1");
                                freeItems.add("Item 2");
                                freeItems.add("Item 3");
                                selectedItems.add("Item 4");
                                selectedItems.add("Item 5");
                      public String save() {
                                return null;
                      public List<String> getFreeItems() {
                                return freeItems;
                      public void setFreeItems(List<String> freeItems) {
                                this.freeItems = freeItems;
                      public List<String> getSelectedItems() {
                                return selectedItems;
                      public void setSelectedItems(List<String> selectedItems) {
                                this.selectedItems = selectedItems;




            <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
            <html xmlns="http://www.w3.org/1999/xhtml"
                                          <rich:messages />
                                                              <h:outputText value="#{item}"></h:outputText>
                                                    <f:selectItems value="#{pickList.freeItems}" var="item" itemLabel="#{item}" itemValue="#{item}"/>
                                          <a:commandButton action="#{pickList.save}" value="Save" /> 
            • 3. Re: RF 4.2 - pickList doesn't use value attribute
              iabughosh Master

              add also item 4 and item 5 to the free items, free items must contain all the items, selected or not.

              • 4. Re: RF 4.2 - pickList doesn't use value attribute
                Piotr Czekaj Newbie

                Thank you for you help, rich:pickList works as expected for both collection of strings and also my custom objects. Adding all elements to "freeItems" helped, that's the difference between using RF 3.3 rich:listShuttle and RF 4.2 rich:pickList.