myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monkeyden <monkey...@gmail.com>
Subject Re: Converter error
Date Fri, 03 Nov 2006 00:06:31 GMT

Ok, removing the value attribute of the selectManyListBox got rid of that
issue but, on a related topic, it doesn't appear that the "valueChangeEvent"
and "immediate" attributes are having any effect.  I'm doing some other
client side stuff, but performing the dblclick on the list box allow
validation to happen for that component and the listener method is never
called.

Here is the use case:
1.  User selects a state from a list of 5 radio buttons.
2.  "Available Locations" is populated with the locations available within
selected state
3.  User selects locations from that list to add to User Locations
(editProfileAction.userLocations)
4.  Double clicking a "User Location" will result in it being removed from
the "User Locations" and submission of the form, to change the model.

The code below results in the following error every "Selected Location"
which was moved over from "Available Locations":
Validation Error "userLocations": Value is not a valid option.

<h:selectManyListbox immediate="true" id="userLocations"
    size="11" styleClass="selectBox"
    valueChangeListener="#{editProfileAction.updateUserLocations}"
    ondblclick="submit();">
    <f:selectItems value="#{editProfileAction.userLocations}"/>
</h:selectManyListbox>



Simon Kitching-3 wrote:
> 
> I didn't mention anything about a value change listener.
> 
> You have
>    value="#{editProfileAction.updateUserLocations}"
> which I think is the cause of your problem.
> 
> And I didn't say it was complaining *about* the component id. I'm saying 
> it is complaining about the component which has an id of 
> "userLocations". You appear to have interpreted this as a problem with 
> the *method* getUserLocations which I don't think is the case.
> 
> Regards,
> 
> Simon
> 
> monkeyden wrote:
>> Is the valueChangeListener supposed to return a String?  I was under the
>> impression that it's supposed to return void, like
>> ValueChangeListener.processValueChange(ValueChangeEvent event).
>>
>> Why would it be complaining about the component id?
>>
>> I wasn't quite clear enough in my description.  This particular select
>> box
>> is expected to contain, and to submit, several items, so the mutator
>> (setter) will also take an array.  It's a Collection, owned by a user.
>>
>>
>> Simon Kitching-3 wrote:
>>   
>>> It looks to me like your method "editProfileAction.updateUserLocations" 
>>> is not returning a string. The complaint about "userLocations" is 
>>> referring to the component id, not a method name.
>>>
>>> Value should be a binding to a property (ie get/set methods). When 
>>> rendering, the getter is called and expects a value that matches the 
>>> "value" property of one of the SelectItem objects from the f:selectItems 
>>> child.
>>> When the user selects a different SelectItem from the list, the setter 
>>> is called, passing the "value" of whatever SelectItem the user chose..
>>>
>>> Regards,
>>>
>>> Simon
>>>
>>> monkeyden wrote:
>>>     
>>>> I am getting a converter error when trying to pass an array of
>>>> SelectItems to
>>>> a selectManyListbox.  Isn't this component designed to handle an array? 
>>>> Why
>>>> would I need a converter?  Note, these are pre-selected items.  That's
>>>> why
>>>> the value of the selectManyListbox is the same as <f:selectItems/>
>>>>
>>>> JSF:
>>>> <h:selectManyListbox immediate="true" id="userLocations" 
>>>>     value="#{editProfileAction.updateUserLocations}"
>>>>     size="11" styleClass="selectBox"
>>>>     valueChangeListener="#{editProfileAction.updateUserLocations}">
>>>>     <f:selectItems value="#{editProfileAction.userLocations}"/>
>>>> </h:selectManyListbox>
>>>>
>>>>
>>>> Java:
>>>> private SelectItem[] userLocations;
>>>> ...
>>>> public SelectItem[] getUserLocations() {
>>>>     return userLocations;
>>>> }
>>>>
>>>> public SelectItem[] getUserLocations() {
>>>>     return userLocations;
>>>> }
>>>> ...
>>>> Result:
>>>> java.lang.IllegalArgumentException: Value is no String and component
>>>> alertsSubView:alertsForm:userLocations does not have a Converter
>>>> 	at
>>>> org.apache.myfaces.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:544)
>>>> 	at
>>>>
>>>>   
>>>>       
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Converter-error-tf2564573.html#a7149133
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message