You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Juan Ignacio Sánchez Lara <ju...@gmail.com> on 2007/05/17 15:41:40 UTC

Changing String default converter

JSF by default assign empty string at backing bean properties when a form is
sent. I want to override that with a custom converter. My problem is my
converter is never called. This is the code at faces-config.xml:

        <converter>
		<converter-for-class>java.lang.String</converter-for-class>
		<converter-class>
			myPackage.NullableStringConverter
		</converter-class>

	</converter>



If I set breakpoints inside getAsObject or getAsString I see it doesn't
stops there. What am I doing wrong?

-- 
Juan Ignacio Sánchez Lara
Ingeniero Informático + Técnico de Sistemas

Diario: http://juanignaciosl.blogspot.com
Fotos (todas): http://www.flickr.com/photos/juanignaciosl
Fotos (selección): http://jpgmag.com/people/juanignaciosl

Re: Changing String default converter

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes.

Or depending on what you're doing, there might be other ways to handle it.
For most of my needs, I only needed null rather than empty string when
saving data to a database, so I changed my database layer software to
perform the empty-string-to-null conversion at that point.

For the few other places I needed to check (business logic), I checked
against both null and empty string.


On 5/17/07, Juan Ignacio Sánchez Lara <ju...@gmail.com> wrote:
> So I assume I must wait till myfaces-1.2.something :-\ Till then I'll use
> explicit converter selection...
>
> Thank you very much!
>
>
> On 5/17/07, Mike Kienenberger <mk...@gmail.com> wrote:
> > Registered "automatic" by-class String (and Object) converters are not
> > allowed in JSF 1.1.
> >
> > It's been fixed for JSF 1.2.
> >
> >
> https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=131
> >
> >
> > On 5/17/07, Juan Ignacio Sánchez Lara <ju...@gmail.com> wrote:
> > > JSF by default assign empty string at backing bean properties when a
> form is
> > > sent. I want to override that with a custom converter. My problem is my
> > > converter is never called. This is the code at faces-config.xml:
> > >
> > >  <converter>
> > >  <converter-for-class> java.lang.String</converter-for-class>
> > >  <converter-class>
> > >  myPackage.NullableStringConverter
> > >  </converter-class>
> > >
> > >
> > >  </converter>
> > >
> > >
> > >
> > > If I set breakpoints inside getAsObject or getAsString I see it doesn't
> > > stops there. What am I doing wrong?
> > >
> > > --
> > > Juan Ignacio Sánchez Lara
> > > Ingeniero Informático + Técnico de Sistemas
> > >
> > > Diario: http://juanignaciosl.blogspot.com
> > > Fotos (todas):
> http://www.flickr.com/photos/juanignaciosl
> > > Fotos (selección):
> http://jpgmag.com/people/juanignaciosl
> >
>
>
>
> --
>
> Juan Ignacio Sánchez Lara
> Ingeniero Informático + Técnico de Sistemas
>
> Diario: http://juanignaciosl.blogspot.com
> Fotos (todas): http://www.flickr.com/photos/juanignaciosl
> Fotos (selección): http://jpgmag.com/people/juanignaciosl

Re: Changing String default converter

Posted by Juan Ignacio Sánchez Lara <ju...@gmail.com>.
So I assume I must wait till myfaces-1.2.something :-\ Till then I'll use
explicit converter selection...

Thank you very much!

On 5/17/07, Mike Kienenberger <mk...@gmail.com> wrote:
>
> Registered "automatic" by-class String (and Object) converters are not
> allowed in JSF 1.1.
>
> It's been fixed for JSF 1.2.
>
>
> https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=131
>
>
> On 5/17/07, Juan Ignacio Sánchez Lara <ju...@gmail.com> wrote:
> > JSF by default assign empty string at backing bean properties when a
> form is
> > sent. I want to override that with a custom converter. My problem is my
> > converter is never called. This is the code at faces-config.xml:
> >
> >  <converter>
> >  <converter-for-class>java.lang.String</converter-for-class>
> >  <converter-class>
> >  myPackage.NullableStringConverter
> >  </converter-class>
> >
> >
> >  </converter>
> >
> >
> >
> > If I set breakpoints inside getAsObject or getAsString I see it doesn't
> > stops there. What am I doing wrong?
> >
> > --
> > Juan Ignacio Sánchez Lara
> > Ingeniero Informático + Técnico de Sistemas
> >
> > Diario: http://juanignaciosl.blogspot.com
> > Fotos (todas): http://www.flickr.com/photos/juanignaciosl
> > Fotos (selección): http://jpgmag.com/people/juanignaciosl
>



-- 
Juan Ignacio Sánchez Lara
Ingeniero Informático + Técnico de Sistemas

Diario: http://juanignaciosl.blogspot.com
Fotos (todas): http://www.flickr.com/photos/juanignaciosl
Fotos (selección): http://jpgmag.com/people/juanignaciosl

Re: Changing String default converter

Posted by Mike Kienenberger <mk...@gmail.com>.
Registered "automatic" by-class String (and Object) converters are not
allowed in JSF 1.1.

It's been fixed for JSF 1.2.

https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=131


On 5/17/07, Juan Ignacio Sánchez Lara <ju...@gmail.com> wrote:
> JSF by default assign empty string at backing bean properties when a form is
> sent. I want to override that with a custom converter. My problem is my
> converter is never called. This is the code at faces-config.xml:
>
>  <converter>
>  <converter-for-class>java.lang.String</converter-for-class>
>  <converter-class>
>  myPackage.NullableStringConverter
>  </converter-class>
>
>
>  </converter>
>
>
>
> If I set breakpoints inside getAsObject or getAsString I see it doesn't
> stops there. What am I doing wrong?
>
> --
> Juan Ignacio Sánchez Lara
> Ingeniero Informático + Técnico de Sistemas
>
> Diario: http://juanignaciosl.blogspot.com
> Fotos (todas): http://www.flickr.com/photos/juanignaciosl
> Fotos (selección): http://jpgmag.com/people/juanignaciosl