You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by sugandh <su...@relianceada.com> on 2007/06/11 08:26:08 UTC

Re: Fwd: Selected values of ...

Hi Bruno,
You get the array of string when you do valueChangedEvent.getNewValue().
>From thyis you can get the new values that have been added.
There is a getOldValue() also but oddly, it keeps on throwing null pointer
exception.
Sugandh

Bruno Aranda wrote:
> 
> Please, send the mails to the user list where you will get answers sooner,
> 
> Regards,
> 
> Bruno
> 
> ---------- Forwarded message ----------
> From: mail2bansi@yahoo.com <ma...@yahoo.com>
> Date: 15-Jan-2007 20:34
> Subject: Re: Selected values of <h:selectManyListbox> ...
> To: brunoaranda@gmail.com
> 
> Hi Bruno
> I have a similar situation
> 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:selectItems value="#{test.userRoles}" />
> </h:selectManyListbox>
> 
> 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;
> 
> }
> 
> Any pointers/suggestions will be highly appreciated
> 
> Regards
> Bansi
> Bruno Aranda wrote:
>>
>> I don't know if I undersantd you correctly. How do you create the List
>> of SelectItems called 'countryDepartmentItems'? When you do
>> event.getNewValue() in the valueChangeListener method you obtain the
>> selected values as an array of the values of the SelectItem objects.
>> Then, you should do whatever logic you need with this values...
>>
>> Regards,
>>
>> Bruno
>>
>> 2005/7/23, fabio quimbay <fa...@gmail.com>:
>>> Greetings, ...
>>>
>>> This is a part of my JSP page:
>>>
>>> ...
>>> <h:selectManyListbox id="countryDepartments" size="3"
>>> value="#{project.selectedCountryDepartments}"
>>> valueChangeListener="#{project.handleCountryDepartments}"
>>> onchange="submit()" immediate="true">
>>>    <f:selectItems value="#{project.countryDepartmentItems}"/>
>>> </h:selectManyListbox>
>>> ...
>>>
>>> And in my Backing Bean:
>>>
>>> ...
>>> public void handleCountryDepartments(ValueChangeEvent event) {
>>>    Object listbox = event.getNewValue();
>>> }
>>>
>>> the listbox Object has a the values [30, 13], but I can't accede to
>>> its positions; I explain myself, I can't do:
>>>
>>>   ...
>>>   List<UIComponent> countryDepartmentsId =
>>> event.getComponent().getChildren();
>>>   HtmlSelectManyListbox listbox =
>>> (HtmlSelectManyListbox)event.getNewValue();
>>>   ...
>>>
>>> I don't know how acceding to those values. How I can do it ? Thanks
>>> for your help ...
>>> --
>>> fabio quimbay
>>>
>>
>>
> Quoted from:
> http://www.nabble.com/Selected-values-of-%3Ch%3AselectManyListbox%3E-...-tf167519.html#a469362
> 
> 

-- 
View this message in context: http://www.nabble.com/Fwd%3A-Selected-values-of-%3Ch%3AselectManyListbox%3E-...-tf3017103.html#a11055635
Sent from the MyFaces - Users mailing list archive at Nabble.com.