2 Replies Latest reply on Sep 26, 2008 9:12 AM by 658179

    preselection in af:selectmany


      I did find this thread about preselection of af:selectManyListBoxes, but I didn't really understand the answer.

      how to : pre select values in SelectManyListBox

      Can someone give me a hint with this. I did ask for help in the other thread, but it doesn't seem that anyone is taking a look at it anymore, because it is already marked as "Correctly Answered".

      I did use the blog of Frank Nimphius (ADF Faces: Working with the af:selectManyListsbox Part 1 and Part 2), but in the blog there is nothing mentioned about how to preselect different values.

      Thank You
        • 1. Re: preselection in af:selectmany
          Hi Bodhy,

          Try the following:

          In the page:
          <af:selectManyCheckbox value="#{bean.selectedElements}" simple="true">
            <f:selectItems value="#{bean.listOfValues}"/>
          In the bean:
          public class MyBean
              private static final List<SelectItem> LOV;
              private Collection<String> selected;
                  List<SelectItem> temp = new ArrayList<SelectItem>(5);
                  temp.add(new SelectItem("value1", "label1"));
                  temp.add(new SelectItem("value2", "label2"));
                  temp.add(new SelectItem("value3", "label3"));
                  temp.add(new SelectItem("value4", "label4"));
                  temp.add(new SelectItem("value4", "label5"));
                  LOV = Collections.unmodifiableList(temp);
              public MyBean()
                  selected = new ArrayList<String>();
              public List<SelectItem> getListOfValues()
                  return LOV;
              public Collection<String> getSelectedValues()
                  return selected;
              public void setSelectedValues(Collection<String> values)
                  this.selected = values;

          ~ Simon
          • 2. Re: preselection in af:selectmany
            Thank You Simon,

            it is working