Passing SelectItem instances as argument to a method

I am wondering whether its possible to pass instances of SelectItem as argument to a method. Here is the situation

private List selectedUserRoles = new ArrayList<SelectItem>();

I expect setSelectedUserRoles method to recieve instances of SelectItem with Id and Value as arguments. For example how do i pass the value "new SelectItem("10","Admin")" etc to the below method :

public void setSelectedUserRoles(List selectedUserRoles) {

this.selectedUserRoles = selectedUserRoles;

System.out.println("Setter this.selectedUserRoles "+ this.selectedUserRoles);

}

The above method recieves only Ids whereas i need both Ids and Values. Here is the snippet from JSP page

<h:selectManyListbox id="userRoles" value="#{ test.selectedUserRoles}">

<f:selectItemsvalue="#{test.userRoles}" />

</h:selectManyListbox>

Any pointers/suggestions will be highly appreciated

Regards

Bansi

[975 byte] By [mail2bansia] at [2007-11-26 15:10:00]
# 1

Forgot to add getUserRoles method.

public List<Role> getUserRoles() {

List allAvailableRoles = new ArrayList<SelectItem>();

allAvailableRoles.add(new SelectItem("10","NAMS Admin"));

allAvailableRoles.add(new SelectItem("20","NAMS Focal"));

allAvailableRoles.add(new SelectItem("30","Network Architect"));

allAvailableRoles.add(new SelectItem("40","DNS Architect"));

allAvailableRoles.add(new SelectItem("50","Network Engineer"));

return allAvailableRoles;

}

mail2bansia at 2007-7-8 9:00:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...