Select All values

Hi

I am new Jsf

I've question how to select all values from SelectManyListbox through a

button.

I could able to add and remove values to SelectmanyListbox through inputTex but at the same time I want to select all values on a button click

could anybody please explain me how to do this with small example.

any help is appreciated.

Thanks in advance

[399 byte] By [Dravid1973a] at [2007-11-26 21:47:16]
# 1
any help please
Dravid1973a at 2007-7-10 3:37:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
You can preselect values by just adding those values to the list behind the valuebinding of the listbox.
BalusCa at 2007-7-10 3:37:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thanks BaluC,It'll be great if you could explain with a piece of code.thanks in advance
Ruthera at 2007-7-10 3:37:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
any help BaluC
Ruthera at 2007-7-10 3:37:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

<h:selectManyListbox value="#{myBean.selectedItems}">

<f:selectItems value="#{myBean.selectItems}" />

</h:selectManyListbox>

<h:commandButton value="select all" action="#{myBean.selectAllItems}" />

private List < T > selectedItems;

private List < SelectItem < T, String > > selectItems;

// + getters + setters

public void selectAllItems() {

if (selectedItems == null) {

selectedItems = new ArrayList < T >;

} else {

selectedItems.clear();

}

for (SelectItem selectItem : selectItems) {

selectedItems.add(selectItem.getValue());

}

}

BalusCa at 2007-7-10 3:37:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Thanks BaluC it's working
Ruthera at 2007-7-10 3:37:29 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...