hi,
I have used twoListSelection Component in my project.
at first step I bind available items to left List , then i drop some of items to right List ,after that ,i save available i and selectedI tems in database.
at second step i need to load both of lists(available and selected ) in a twoListSelection component and edit items.
for example droping more items to right list ,or removing some items from right list ,or changing order of selected items.
I dont know how to bind selected items to right List.
i any body knows ,plz help me.
thanx
samaneh
Hello Samaneh,
List of selected items (right list) should be specified with value attribute of the .
Please feel free to ask us if you have any further questions.
Regards,
Tatyana
hello Tatyana
thank you for your reply.
this is part of my code:
<q:twoListSelection leftListboxHeader="availableItems" value="#{testBean.selectedItemList}" rightListboxHeader="selectedItems}" >
<f:selectItems value="#{testBean.itemList}"/>
public List getItemList()
{
itemList=new ArrayList();
itemList.add(new SelectItem("Item1","Item1"));
itemList.add(new SelectItem("Item2","Item2"));
itemList.add(new SelectItem("Item3","Item3"));
return itemList;
}
public List getSelectedItemList()
{
//TODO : define Item4 as defult selectedItem
return selectedNameList;
}
how can I define Item4 as defult selectedItem in right list.
Is below code right?
public List getSelectedItemList()
{
selectedItemList=new ArrayList();
UISelectItem selectItem=new UISelectItem();
selectItem.setItemLabel("Item4");
selectItem.setItemValue("Item4");
selectedItemList.add(selectItem);
return selectedItemList;
}
thanck you
samaneh
Hello Samaneh,
I think that there is some misunderstanding in your usage of the TwoListSelection component. It should be used the same as any of UISelectMany JSF components. The value attribute of the* f:selectItems* component should be bound to a list of all available items. It means that this list should contain items for both (left and right) lists. In your case, it should be as follows:
itemList.add(new SelectItem("Item1","Item1"));
itemList.add(new SelectItem("Item2","Item2"));
itemList.add(new SelectItem("Item3","Item3"));
itemList.add(new SelectItem("Item4","Item4"));
And the value attribute of the q:twoListSelection component should be bound to a list or array of objects that correspond to the itemValue property of f:selectItems component. Given the fact that the itemValue is specified as String, that value attribute of the q:twoListSelection component should be bound to a list or array of String objects.
So, if you know itemValue for the item that should be selected, you should specify the following:
selectedItemList=new ArrayList();
selectedItemList.add("Item4");
Feel free to ask us any further questions.
Regards,
Tatyana