-
1. Re: rich : pickList
ilya_shaikovsky May 28, 2009 10:54 AM (in response to vladomega)check livedemo sample. There are last sample which manages selected objects via ajax.
-
2. Re: rich : pickList
dan.j.allen May 28, 2009 11:00 AM (in response to vladomega)I believe that you treat the rich:pickList just like you would an h:selectManyListbox. It's just a prettier, more user-friendly UI widget. So the value of the component is a list of items that accept the type of each item value.
<h:pickList value="#{bean.selectedItems}"> <f:selectItems value="#{bean.options}"/> </h:pickList>
The property selectedItems would be defined as follows:private List<String> selectedItems; public List<String> getSelectedItems() { return selectedItems; } public setSelectedItems(List<String> items) { this.selectedItems = items; }
And of course the options would be a property which provides a list of SelectItem objects as you have already done. -
3. Re: rich : pickList
vladomega May 30, 2009 11:46 AM (in response to vladomega)The thing is that when I select the items from the list into the right list the participantsSelectItem ArrayList has the initial length with all the objects (not just the ones I copied in the right list - that's the thing I need, an ArrayList with just the objects in the right list).
private ArrayList<SelectItem> participantsSelectItem = new ArrayList<SelectItem>(); public void setParticipantsSelectItem(ArrayList<SelectItem> participants) { this.participantsSelectItem = participants; } public List getParticipantsSelectItem() { participantsSelectItem = new ArrayList(); for (int i=0; i<Authenticator.getParticipants().size();i++) { String fullName = Authenticator.getParticipants().get(i).getFirstName()+" "+Authenticator.getParticipants().get(i).getLastName(); participantsSelectItem.add(new SelectItem(Authenticator.getParticipants().get(i), fullName)); } return participantsSelectItem; }
-
4. Re: rich : pickList
vladomega May 30, 2009 1:54 PM (in response to vladomega)Ok, I succedeed in obtaining the list of object in the right list. The issue is that I obtain an Array$ArrayList of String objects even though in the code below I put in the SelectedItem constructor a Participant Object.
public List getParticipantsSelectItem() { participantsSelectItem = new ArrayList(); for (int i=0; i<Authenticator.getParticipants().size();i++) { String fullName = Authenticator.getParticipants().get(i).getFirstName()+" "+Authenticator.getParticipants().get(i).getLastName(); participantsSelectItem.add(new SelectItem(Authenticator.getParticipants().get(i), fullName)); } return participantsSelectItem; }
And the participants list to where I return the values from the right list: value="#{registerEvent.participants}"<rich:pickList id="pickList" rendered="true" value="#{registerEvent.participants}"> <f:selectItems value="#{registerEvent.participantsSelectItem}"/> </rich:pickList>
My participants list looks like this from debugger:participants=Arrays$ArrayList a=String[3] //there are 3 elements copied in the right list [0]=Participants@1a59ac1 [1]=Participants@... [2]=Participants@....
-
5. Re: rich : pickList
vladomega May 31, 2009 4:13 AM (in response to vladomega)Is there a way to obtain the ArrayList with the Participants objects instead of the list with String objects ?
-
6. Re: rich : pickList
dan.j.allen May 31, 2009 9:59 AM (in response to vladomega)You do have a List, it's just a non-modifiable ArrayList created by Arrays.toList. That is just the way the rich:pickList creates the collection of selected items. In your component, you will have to copy it to create a modifiable ArrayList.
List participantsCopy = new ArrayList(participates); -
7. Re: rich : pickList
vladomega Jun 1, 2009 3:45 AM (in response to vladomega)Ok, I make that list, but the problem remains the same. The new list has the objects i selected but are not the participants objects, are the same string objects. Each index of the list has an element like this: "Participants@2f6c.." and it's something like the signature of the object - a string a value and not the Participant object itself!!
participantsCopy = ArrayList<E> elementData=Object[3] [0] = "Participants@3f5f1.." [1] = "Participants@.." //.......
I have even parametrize the ArrayCollection with but participantsCopy still remains with parameter when i debug. -
8. Re: rich : pickList
vladomega Jun 1, 2009 3:48 AM (in response to vladomega)I have even parametrize the ArrayCollection with
<Participants>
but participantsCopy still remains with<E>
parameter when i debug. -
9. Re: rich : pickList
dan.j.allen Jun 1, 2009 4:33 AM (in response to vladomega)Stop using ArrayList except for where you construct it. That is where things are getting confused. ArrayList is an implementation of List, not an interface. Therefore, when you have that signature in your method you confuse RichFaces (I have no doubt).