You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by monkeyden <mo...@gmail.com> on 2006/11/03 00:10:22 UTC

Converter error

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
org.apache.myfaces.renderkit.RendererUtils.internalSubmittedOrSelectedValuesAsSet(RendererUtils.java:586)
	at
org.apache.myfaces.renderkit.RendererUtils.getSelectedValuesAsSet(RendererUtils.java:527)
	at
org.apache.myfaces.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:307)
	at
org.apache.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:290)
	at
org.apache.myfaces.renderkit.html.HtmlRendererUtils.renderListbox(HtmlRendererUtils.java:241)
	at
org.apache.myfaces.renderkit.html.HtmlListboxRendererBase.encodeEnd(HtmlListboxRendererBase.java:56)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
	at
org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
	at
org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
	at
org.apache.myfaces.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:62)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
	at
org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:442)
	at
org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.writeTabsContents(HtmlTabbedPaneRenderer.java:530)
	at
org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.encodeEnd(HtmlTabbedPaneRenderer.java:222)
	at
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)


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


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
By the way, here is the signature for the mutator:

public void setUserLocations(SelectItem[] selectedLocations);

Is it expecting a String[] instead or will it convert for me?


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
> org.apache.myfaces.renderkit.RendererUtils.internalSubmittedOrSelectedValuesAsSet(RendererUtils.java:586)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.getSelectedValuesAsSet(RendererUtils.java:527)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:307)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:290)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.renderListbox(HtmlRendererUtils.java:241)
> 	at
> org.apache.myfaces.renderkit.html.HtmlListboxRendererBase.encodeEnd(HtmlListboxRendererBase.java:56)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:62)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:442)
> 	at
> org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.writeTabsContents(HtmlTabbedPaneRenderer.java:530)
> 	at
> org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.encodeEnd(HtmlTabbedPaneRenderer.java:222)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 
> 
> 

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


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
I am also under the assumption that any selectOneXxx could take a SelectItem
and any selectManyXxx could take a collection/array/map of SelectItems,
without having to use a converter.


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
> org.apache.myfaces.renderkit.RendererUtils.internalSubmittedOrSelectedValuesAsSet(RendererUtils.java:586)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.getSelectedValuesAsSet(RendererUtils.java:527)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.getSubmittedOrSelectedValuesAsSet(HtmlRendererUtils.java:307)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:290)
> 	at
> org.apache.myfaces.renderkit.html.HtmlRendererUtils.renderListbox(HtmlRendererUtils.java:241)
> 	at
> org.apache.myfaces.renderkit.html.HtmlListboxRendererBase.encodeEnd(HtmlListboxRendererBase.java:56)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:203)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:85)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:450)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448)
> 	at
> org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427)
> 	at
> org.apache.myfaces.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:62)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 	at
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:442)
> 	at
> org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.writeTabsContents(HtmlTabbedPaneRenderer.java:530)
> 	at
> org.apache.myfaces.custom.tabbedpane.HtmlTabbedPaneRenderer.encodeEnd(HtmlTabbedPaneRenderer.java:222)
> 	at
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331)
> 
> 
> 

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


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
Here is the reply to which I was referring.  I suspect that, if correct, this
is the root cause of my problem.  Is this true?  What selectlist is it
referring to?  The value attribute of the selectManyListBox?


"...when a component that extends from UISelectOne (UISelectMany in my case)
is validated, the local value of the component is checked to figure out
whether this value is in the selectitems list or not. If not then the value
is not valid."



monkeyden wrote:
> 
> Let me take another stab at explaining my use case, in hopes of
> determining why validation is firing for the submitted values.  I read
> something about Options not being valid if they aren't in the "master"
> list, specified by the value attribute of <h:selectManyListbox>, and
> wanted to figure out if that is what's happenign in my case.
> 
> Components:
> US State radios [selectOneRadio]
> availableLocations [selectManyListbox]
> selectedLocations [selectManyListbox]
> 
> Data Model:
> globalLocations - global list of all locations for all states
> availableLocations - state-specific subset of globalLocations
> selectedLocations - locations the user has chosen, regardless of state
> 
> Use Case:
> 1.  On load, selectedLocations is populated with locations already
> associated with the user
> 2.  User selects one of the "US State" radios to retrieve
> availableLocations, a state-specific subset of globalLocations (this works
> fine) 
> 3.  User selects one of availableLocations, which is added to
> selectedLocations. (this works fine)
> 4.  User can choose to remove a selectedLocation by double clicking on it. 
> Need to update the model in this case, so JavaScript selects all
> selectedLocations and submits the form.
> 5.  User submits the form, to update his selectedLocations
> 
> Relevant Code:
> <%-- STATE RADIO BUTTONS --%>
> <h:selectOneRadio immediate="true" id="stateRadios"
> 	onclick="submit()"
> valueChangeListener="#{editProfileAction.processStateChange}"
> 	styleClass="bodyCopy">
> 	<f:selectItem itemLabel="MA" itemValue="MA"/>
> 	<f:selectItem itemLabel="ME" itemValue="ME"/>
> 	<f:selectItem itemLabel="NH" itemValue="NH"/>
> 	<f:selectItem itemLabel="RI" itemValue="RI"/>
> 	<f:selectItem itemLabel="VT" itemValue="VT"/>
> </h:selectOneRadio>
> <%-- AVAILABLE LOCATIONS --%>
> <h:selectManyListbox id="availableLocations" size="11"
> styleClass="selectBox"
> 
> ondblclick="fnDualSelectChoice1('alertsSubView:alertsForm','alertsSubView:alertsForm:availableLocations',
> 'alertsSubView:alertsForm:userLocations',
> 'alertsSubView:alertsForm:stateRadios');return false;">
> 	<f:selectItems value="#{availableLocations}"/>
> </h:selectManyListbox>
> <%-- SELECTED LOCATIONS --%>
> <h:selectManyListbox immediate="true" id="userLocations"
> 	size="11" styleClass="selectBox"
> 	valueChangeListener="#{editProfileAction.updateUserLocations}"
> 
> ondblclick="fnDualSelectChoice2('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations',
> 'alertsSubView:alertsForm:availableLocations',
> 'alertsSubView:alertsForm:stateRadios');fnSelectAllValues('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations');submit();">
> 	<f:selectItems value="#{editProfileAction.userLocations}"/>
> </h:selectManyListbox>
> <%-- SAVE BUTTON --%>
> <h:commandButton immediate="true" id="save" type="submit" value="Save
> Alerts & Searches" action="#{editProfileAction.saveAlertsAndSearch}"
> styleClass="formButtonXL"
> onclick="fnSelectAllValues('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations');"/>
> 
> The behavior I'm seeing is that when the user removes the value from
> selectedLocations (Step 4):
> 1.  The value is removed via JavaScript (expected)
> 2.  All the userLocation values are selected (expected)
> 3.  The form is submitted (expected)
> 4.  For every value the user added on the client, I get this message:
> "Validation Error "userLocations": Value is not a valid option."
> 
> From everything that I have read, and my interpretation thereof, this
> validation shouldn't be happening due to immediate="true".  I'm sure there
> is a valid explanation for this error, I'm just ignorant of it at this
> point.  Does anyone have any insight?
> 
> Sorry for the long winded post.  This is a pretty rare and somewhat
> complex requirement.
> 
> 
> 
> 

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


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
Let me take another stab at explaining my use case, in hopes of determining
why validation is firing for the submitted values.  I read something about
Options not being valid if they aren't in the "master" list, specified by
the value attribute of <h:selectManyListbox>, and wanted to figure out if
that is what's happenign in my case.

Components:
US State radios [selectOneRadio]
availableLocations [selectManyListbox]
selectedLocations [selectManyListbox]

Data Model:
globalLocations - global list of all locations for all states
availableLocations - state-specific subset of globalLocations
selectedLocations - locations the user has chosen, regardless of state

Use Case:
1.  On load, selectedLocations is populated with locations already
associated with the user
2.  User selects one of the "US State" radios to retrieve
availableLocations, a state-specific subset of globalLocations (this works
fine) 
3.  User selects one of availableLocations, which is added to
selectedLocations. (this works fine)
4.  User can choose to remove a selectedLocation by double clicking on it. 
Need to update the model in this case, so JavaScript selects all
selectedLocations and submits the form.
5.  User submits the form, to update his selectedLocations

Relevant Code:
<%-- STATE RADIO BUTTONS --%>
<h:selectOneRadio immediate="true" id="stateRadios"
	onclick="submit()"
valueChangeListener="#{editProfileAction.processStateChange}"
	styleClass="bodyCopy">
	<f:selectItem itemLabel="MA" itemValue="MA"/>
	<f:selectItem itemLabel="ME" itemValue="ME"/>
	<f:selectItem itemLabel="NH" itemValue="NH"/>
	<f:selectItem itemLabel="RI" itemValue="RI"/>
	<f:selectItem itemLabel="VT" itemValue="VT"/>
</h:selectOneRadio>
<%-- AVAILABLE LOCATIONS --%>
<h:selectManyListbox id="availableLocations" size="11"
styleClass="selectBox"

ondblclick="fnDualSelectChoice1('alertsSubView:alertsForm','alertsSubView:alertsForm:availableLocations',
'alertsSubView:alertsForm:userLocations',
'alertsSubView:alertsForm:stateRadios');return false;">
	<f:selectItems value="#{availableLocations}"/>
</h:selectManyListbox>
<%-- SELECTED LOCATIONS --%>
<h:selectManyListbox immediate="true" id="userLocations"
	size="11" styleClass="selectBox"
	valueChangeListener="#{editProfileAction.updateUserLocations}"

ondblclick="fnDualSelectChoice2('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations',
'alertsSubView:alertsForm:availableLocations',
'alertsSubView:alertsForm:stateRadios');fnSelectAllValues('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations');submit();">
	<f:selectItems value="#{editProfileAction.userLocations}"/>
</h:selectManyListbox>
<%-- SAVE BUTTON --%>
<h:commandButton immediate="true" id="save" type="submit" value="Save Alerts
& Searches" action="#{editProfileAction.saveAlertsAndSearch}"
styleClass="formButtonXL"
onclick="fnSelectAllValues('alertsSubView:alertsForm','alertsSubView:alertsForm:userLocations');"/>

The behavior I'm seeing is that when the user removes the value from
selectedLocations (Step 4):
1.  The value is removed via JavaScript (expected)
2.  All the userLocation values are selected (expected)
3.  The form is submitted (expected)
4.  For every value the user added on the client, I get this message:
"Validation Error "userLocations": Value is not a valid option."

>From everything that I have read, and my interpretation thereof, this
validation shouldn't be happening due to immediate="true".  I'm sure there
is a valid explanation for this error, I'm just ignorant of it at this
point.  Does anyone have any insight?

Sorry for the long winded post.  This is a pretty rare and somewhat complex
requirement.



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


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
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.


Re: Converter error

Posted by Simon Kitching <si...@rhe.co.nz>.
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
>>>
>>>   
>>>       
>>
>>     
>
>   


Re: Converter error

Posted by monkeyden <mo...@gmail.com>.
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#a7148749
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Converter error

Posted by Simon Kitching <si...@rhe.co.nz>.
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
>
>