You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Michael <mp...@gmail.com> on 2005/09/08 16:55:15 UTC

SelectItem and Converters

Hi all,

I apologize if this question is answered elsewhere but I didn't have any 
luck with the mailing list archive, JIRA, or google.

I have an array of SelectItem objects with the value set to a Java 5 
enumeration. If I register a custom converter using converter-for-class, I'd 
expect to be able to bind the SelectItem array to a selectOneMenu and the 
converter would be called automatically.

Instead, my converter is never called. Further,
Application.createConverteris never called either (I set a breakpoint
there). I get the following
exception:
java.lang.IllegalArgumentException: Value is no String and component 
someClientId does not have a Converter

I looked at the code and it seems that
RendererUtils.getConvertedStringValuedoes not check to see if a class
converter exists. It only uses the
converter passed to it (which looking in HtmlRendererUtils, is the converter 
associated with the UIComponent).

I know there was some mention of this in MYFACES-131 but it was closed as a 
duplicate with no reference (at least that I could find) to the original 
bug.

Am I missing something or should this be filed as a bug?

Thanks,
Michael

Re: SelectItem and Converters

Posted by Caroline Jen <ji...@yahoo.com>.
Sorry about my ignorance.  What is "myfaces svn
snapshot"?

--- Mike Kienenberger <mk...@gmail.com> wrote:

> I'm using selectOneMenus with arrays of selectItems
> and converters
> without any problem with a myfaces svn snapshot from
> 2005-08-16 (I'm a
> couple weeks out of date because I had to work on a
> non-JSF project
> for a bit).
> 
> It sounds like your converter isn't properly
> registered.
> I think createConverter is only called after the
> appropriate converter
> type to create is identified, so you really need to
> be setting a
> breakpoint in the "findConverterToCreate" method (I
> don't remember the
> name or location offhand, but if you start in
> UIInput, you should be
> able to find it fairly quickly.  Alternately, you
> can just set a
> breakpoing in UIInput.)
> 
> -Mike
> 
> On 9/8/05, Michael <mp...@gmail.com> wrote:
> > Hi all,
> >  
> >  I apologize if this question is answered
> elsewhere but I didn't have any
> > luck with the mailing list archive, JIRA, or
> google.
> >  
> >  I have an array of SelectItem objects with the
> value set to a Java 5
> > enumeration.  If I register a custom converter
> using converter-for-class,
> > I'd expect to be able to bind the SelectItem array
> to a selectOneMenu and
> > the converter would be called automatically.
> >  
> >  Instead, my converter is never called.  Further,
> > Application.createConverter is never called either
> (I set a breakpoint
> > there).  I get the following exception:
> >  java.lang.IllegalArgumentException: Value is no
> String and
> > component someClientId does not have a Converter
> >  
> >  I looked at the code and it seems that
> > RendererUtils.getConvertedStringValue does not
> check to see
> > if a class converter exists.  It only uses the
> converter passed to it (which
> > looking in HtmlRendererUtils, is the converter
> associated with the
> > UIComponent).
> >  
> >  I know there was some mention of this in
> MYFACES-131 but it was closed as a
> > duplicate with no reference (at least that I could
> find) to the original
> > bug.
> >  
> >  Am I missing something or should this be filed as
> a bug?
> >  
> >  Thanks,
> >  Michael
> >
> 



	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

Re: SelectItem and Converters

Posted by Mike Kienenberger <mk...@gmail.com>.
I'm using selectOneMenus with arrays of selectItems and converters
without any problem with a myfaces svn snapshot from 2005-08-16 (I'm a
couple weeks out of date because I had to work on a non-JSF project
for a bit).

It sounds like your converter isn't properly registered.
I think createConverter is only called after the appropriate converter
type to create is identified, so you really need to be setting a
breakpoint in the "findConverterToCreate" method (I don't remember the
name or location offhand, but if you start in UIInput, you should be
able to find it fairly quickly.  Alternately, you can just set a
breakpoing in UIInput.)

-Mike

On 9/8/05, Michael <mp...@gmail.com> wrote:
> Hi all,
>  
>  I apologize if this question is answered elsewhere but I didn't have any
> luck with the mailing list archive, JIRA, or google.
>  
>  I have an array of SelectItem objects with the value set to a Java 5
> enumeration.  If I register a custom converter using converter-for-class,
> I'd expect to be able to bind the SelectItem array to a selectOneMenu and
> the converter would be called automatically.
>  
>  Instead, my converter is never called.  Further,
> Application.createConverter is never called either (I set a breakpoint
> there).  I get the following exception:
>  java.lang.IllegalArgumentException: Value is no String and
> component someClientId does not have a Converter
>  
>  I looked at the code and it seems that
> RendererUtils.getConvertedStringValue does not check to see
> if a class converter exists.  It only uses the converter passed to it (which
> looking in HtmlRendererUtils, is the converter associated with the
> UIComponent).
>  
>  I know there was some mention of this in MYFACES-131 but it was closed as a
> duplicate with no reference (at least that I could find) to the original
> bug.
>  
>  Am I missing something or should this be filed as a bug?
>  
>  Thanks,
>  Michael
>