Hi Cagatay
Thanks for response. I am not using Tomahawk . But wondering how to create
selectitems manually. 
In my situation i just need to pass instance of SelectItem as an argument to
the method setSelectedUserRoles.
Hence i change the declaration to 
private List selectedUserRoles = new ArrayList<SelectItem>();

But i expect setSelectedUserRoles method to recieve instances of SelectItem
with Id and Value as arguments whenever user selects items from the user
role list box
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);
}

Regards
Bansi







Cagatay Civici wrote:
> 
> Hi,
> 
> As I said, in order to use t:selectItems you need the latest tomahawk
> snapshot. It's just a shortcut, of course you can create selectitems
> manually.
> 
> Cagatay
> 
> On 1/15/07, bansi <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hi Cagatay
>> Thanks for your response.
>> The following code in Add Role method results in error
>> public String addRole() {
>>         deviceRoles.addAll(selectedUserRoles);
>>         return null;
>> }
>>
>> ERROR:
>> javax.faces.FacesException: Collection referenced by UISelectItems with
>> binding
>>
>> '#{test.deviceRoles}' and Component-Path : {Component-Path : [Class:
>>
>> org.ajax4jsf.framework.ajax.AjaxViewRoot,ViewId: /page.jsp][Class:
>>
>> javax.faces.component.html.HtmlForm,Id: _id0][Class:
>>
>> org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel,Id: _id6][Class:
>>
>> javax.faces.component.html.HtmlPanelGrid,Id: _id13][Class:
>>
>> javax.faces.component.html.HtmlSelectManyListbox,Id: _id19][Class:
>>
>> javax.faces.component.UISelectItems,Id: _id20]} does not contain Objects
>> of
>> type
>>
>> SelectItem
>>
>>
>>
>> I fixed the error by  hardcoding the values into Add Role method as shown
>> below
>>
>> public String addRole() {
>>
>>         deviceRoles.add(new SelectItem("10"," Admin"));
>>         deviceRoles.add(new SelectItem("20"," Focal"));
>>         deviceRoles.add(new SelectItem("30","Architect"));
>>
>>         return null;
>> }
>>
>> So I guess the call to "selectedUserRoles" in
>> deviceRoles.addAll(selectedUserRoles); should
>>
>> return instances of SelectItem with Id and Value  as arguments.
>>
>> That means whenever users selects multiple values from user roles select
>> box, the
>>
>> setselectedUserRoles() method should recieve both Id and Value as
>> instance
>> of Select Item.
>>
>> Hence i changed the declaration to
>> private List selectedUserRoles = new ArrayList<SelectItem>();
>>
>> But not sure how to change the defination of setselectedUserRoles()
>> method
>> to recieve
>>
>> instances of SelectItem with Id and Value as Arguments. Here is the
>> defination
>>
>> public void setSelectedUserRoles(List selectedUserRoles) {
>>         this.selectedUserRoles = selectedUserRoles;
>>         System.out.println("Setter this.selectedUserRoles "+
>> this.selectedUserRoles);//prints
>>
>>                                         only Id. I wanna print both Id
>> and
>> Value so
>>
>>                                 that i can pass bot Id and value to
>> device
>> roles
>> }
>>
>>
>>
>>
>> Any pointers/suggestions will be highly appreciated in this regard.
>> Here is the  code snippet in backing bean :
>>
>> --------------------------------
>> TestBean.java (Backing Bean)
>> ------------------------------------
>> private List<Role> userRoles;
>> private List deviceRoles = new ArrayList<SelectItem>();
>> private List selectedUserRoles = new ArrayList<SelectItem>();
>> private List selectedDeviceRoles =  new ArrayList<SelectItem>();
>>
>>
>> public List getSelectedUserRoles() {
>>         System.out.println("Getter this.selectedUserRoles
>> "+selectedUserRoles);
>>         return selectedUserRoles;
>> }
>>
>>
>>
>> public void setSelectedUserRoles(List selectedUserRoles) {
>>         this.selectedUserRoles = selectedUserRoles;
>>         System.out.println("Setter this.selectedUserRoles "+
>> this.selectedUserRoles);//prints
>>
>>                                         only Id. I wanna print both Id
>> and
>> Value so
>>
>>                                 that i can pass bot Id and value to
>> device
>> roles
>> }
>>
>>
>> public String addRole() {
>>         deviceRoles.addAll(selectedUserRoles); //results in error "does
>> not contain
>> Objects
>>
>>                                         of type SelectItem"
>>         return null;
>> }
>>
>> Regards
>> Bansi
>>
>> --
>> View this message in context:
>> http://www.nabble.com/selectManyListBox-to-add-remove-user-Roles-tf2969171.html#a8367455
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/selectManyListBox-to-add-remove-user-Roles-tf2969171.html#a8376421
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to