You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Henri Herscher <he...@gmail.com> on 2005/10/05 23:12:51 UTC

TextField changes behaviour from T3 to T4 ?

Hi,

It looks like a TextField now returns a null string instead of an
empty string. Is there a simple way to revert to the old behaviour ?
I'm getting null pointer exceptions all over the place.

Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: TextField changes behaviour from T3 to T4 ?

Posted by Henri Herscher <he...@gmail.com>.
Thanks for this Marcus, however, it only works like this:

<input jwcid="@TextField" translator="translator:string"/>

As soon as I add "empty=":

<input jwcid="@TextField" translator="translator:string,empty="/>

 I get the following exception:

Unable to instantiate instance of class
org.apache.tapestry.form.translator.StringTranslator:
java.lang.reflect.InvocationTargetException

Any idea what might be wrong ?
Henri

On 06/10/05, Marcus Brito <mb...@gmail.com> wrote:
> Henri Herscher <henri.herscher <at> gmail.com> writes:
>
> > It looks like a TextField now returns a null string instead of an
> > empty string. Is there a simple way to revert to the old behaviour ?
> > I'm getting null pointer exceptions all over the place.
>
> TextField now uses a translator to figure out how to convert the user-typed text
> into the desired target class (different from T3, TextField now can be bound to
> properties of any type, not only String).
>
> The default translator, if not specified, is "translator:string", and
> unfortunately it translates empty strings into as null. You can change this
> behaviour specifying a different translator for your TextField:
>
> <input jwcid="@TextField" translator="translator:string,empty="/>
>
> This looks weird, but should work. As a sidenote, it would be nice if there was
> a global switch or something like this to control this behaviour; you'll usually
> convert ALL your empty strings to null, or keep them ALL as empty strings.
>
> -- Marcus Brito
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: TextField changes behaviour from T3 to T4 ?

Posted by Marcus Brito <mb...@gmail.com>.
Henri Herscher <henri.herscher <at> gmail.com> writes:

> It looks like a TextField now returns a null string instead of an
> empty string. Is there a simple way to revert to the old behaviour ?
> I'm getting null pointer exceptions all over the place.

TextField now uses a translator to figure out how to convert the user-typed text
into the desired target class (different from T3, TextField now can be bound to
properties of any type, not only String).

The default translator, if not specified, is "translator:string", and
unfortunately it translates empty strings into as null. You can change this
behaviour specifying a different translator for your TextField:

<input jwcid="@TextField" translator="translator:string,empty="/>

This looks weird, but should work. As a sidenote, it would be nice if there was
a global switch or something like this to control this behaviour; you'll usually
convert ALL your empty strings to null, or keep them ALL as empty strings.

-- Marcus Brito


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org