You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Leszek Gawron <lg...@mobilebox.pl> on 2008/05/05 14:07:07 UTC

converter can not convert org.myproject.Something to a string

I started getting these as soon as I have used latest wicket trunk in my 
project:

> Caused by: java.lang.IllegalArgumentException: converter can not convert com.mobilebox.pfs.ranking.model.Sex to a string
> 	at org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:392)
> 	at org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
> 	at org.apache.wicket.Component.renderComponent(Component.java:2531)


This leads to:

> 	protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, int index,
> 		String selected)
> 	{
> 		T objectValue = (T)renderer.getDisplayValue(choice);
> 		Class<T> objectClass = (Class<T>)(objectValue == null ? null : objectValue.getClass());
> 
> 		String displayValue = "";
> 		if (objectClass != null && objectClass != String.class)
> 		{
> 			final IConverter<T> converter = this.getConverter(objectClass);
> 
> 			if (!converter.getClass().isAssignableFrom(objectClass))
> 				throw new IllegalArgumentException("converter can not convert " +
> 					objectClass.getName() + " to a string");
> 
> 			displayValue = converter.convertToString(objectValue, getLocale());
> 		}

The check does not seem correct. How can converter class be ever 
assignable to an model object class? Or am I missing something?

-- 
Leszek Gawron                         http://www.mobilebox.pl/krs.html
CTO at MobileBox Ltd.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: converter can not convert org.myproject.Something to a string

Posted by Eelco Hillenius <ee...@gmail.com>.
On Mon, May 5, 2008 at 5:56 AM, Johan Compagner <jc...@gmail.com> wrote:
> that is a wrong check yes
>  its removed.

JIRA?

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: converter can not convert org.myproject.Something to a string

Posted by Johan Compagner <jc...@gmail.com>.
that is a wrong check yes
its removed.

On Mon, May 5, 2008 at 2:07 PM, Leszek Gawron <lg...@mobilebox.pl> wrote:

> I started getting these as soon as I have used latest wicket trunk in my
> project:
>
>  Caused by: java.lang.IllegalArgumentException: converter can not convert
> > com.mobilebox.pfs.ranking.model.Sex to a string
> >        at
> > org.apache.wicket.markup.html.form.AbstractChoice.appendOptionHtml(AbstractChoice.java:392)
> >        at
> > org.apache.wicket.markup.html.form.AbstractChoice.onComponentTagBody(AbstractChoice.java:361)
> >        at
> > org.apache.wicket.Component.renderComponent(Component.java:2531)
> >
>
>
> This leads to:
>
>         protected void appendOptionHtml(AppendingStringBuffer buffer, E
> > choice, int index,
> >                String selected)
> >        {
> >                T objectValue = (T)renderer.getDisplayValue(choice);
> >                Class<T> objectClass = (Class<T>)(objectValue == null ?
> > null : objectValue.getClass());
> >
> >                String displayValue = "";
> >                if (objectClass != null && objectClass != String.class)
> >                {
> >                        final IConverter<T> converter =
> > this.getConverter(objectClass);
> >
> >                        if
> > (!converter.getClass().isAssignableFrom(objectClass))
> >                                throw new
> > IllegalArgumentException("converter can not convert " +
> >                                        objectClass.getName() + " to a
> > string");
> >
> >                        displayValue =
> > converter.convertToString(objectValue, getLocale());
> >                }
> >
>
> The check does not seem correct. How can converter class be ever
> assignable to an model object class? Or am I missing something?
>
> --
> Leszek Gawron                         http://www.mobilebox.pl/krs.html
> CTO at MobileBox Ltd.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>