You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2010/06/18 06:38:09 UTC

Hidden doesn't handle nulls like TextField

When I use a Hidden component on a form for a bean property of type 
Integer with a null value...

<input t:type="hidden" value="myBean.myNullInteger" />

... I get the following error when submitting:

Caused by: java.lang.RuntimeException: Coercion of  to type 
java.lang.Integer (via String --> Long, Long --> Integer) failed: For 
input string: ""
    at 
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:69)
    at 
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:133)

However, if i change the markup to:

<input t:type="textfield" value="myBean.myNullInteger" 
style="display:none;" />

there is no problem.

I guess it's because Hidden doesn't use the default null handler 
(NullFieldStrategy) like TextField, but surely they should behave the 
same in this regard?

bug?

p.

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


Re: Hidden doesn't handle nulls like TextField

Posted by Christophe Cordenier <ch...@gmail.com>.
Hi

2010/6/18 Paul Stanton <pa...@mapshed.com.au>

> When I use a Hidden component on a form for a bean property of type Integer
> with a null value...
>
> <input t:type="hidden" value="myBean.myNullInteger" />
>
> ... I get the following error when submitting:
>
> Caused by: java.lang.RuntimeException: Coercion of  to type
> java.lang.Integer (via String --> Long, Long --> Integer) failed: For input
> string: ""
>   at
> org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:69)
>   at
> org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:133)
>
> However, if i change the markup to:
>
> <input t:type="textfield" value="myBean.myNullInteger"
> style="display:none;" />
>
> there is no problem.
>
> I guess it's because Hidden doesn't use the default null handler
> (NullFieldStrategy) like TextField, but surely they should behave the same
> in this regard?
>

In fact Hidden component uses ValueEncoder to encode/decode the value
parameter :

http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/Hidden.html


>
> bug?
>
> p.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Regards,
Christophe Cordenier.

Developer of wooki @wookicentral.com