Thursday, February 7, 2013

How to retrieve Selected Items from selectManyCheckbox using ValueChnageListener

The selectManyCheckbox component creates a component which allows the user to select many values from a series of checkboxes. Below is the code to retrieve selected items from selectManyCheckbox using ValueChangeListener method.

Note:- valueChangeEvent.getNewValue() will return Object value like [Ljava.lang.Object;@fcfd12, need to loop the object arrayList to get the values.

public void myValueChangeListener(ValueChangeEvent valueChangeEvent) {
        Object[] objArr = (Object[])valueChangeEvent.getNewValue();
        for (int x = 0; x < objArr.length; x++) {
            Object obj = objArr[x];
            System.out.println(obj.toString());
       }
}

In Below image, how the selectManyCheckbox will be displayed at run time and user selected check box values will be displayed in Jdeveloper console.

2 comments:

  1. Hi,
    i am using same code but its giving me index number not a value.

    ReplyDelete
  2. Hi,
    me too getting index number of the rows but not names...

    ReplyDelete