We're definitely getting into some contention here, as others are just as
eloquent that nulls should be coerced to zeros (and that's a code change
that went in last week).

I think this needs more consideration.  I'm thinking this needs to be
decided using a translator and there should be an easy way to handle this
inside BeanEditor.  For example, property type Integer (wrapper type) uses
null when the user input is blank, but type int (the primitive) uses 0.

On 10/3/07, Tom Davies <[EMAIL PROTECTED]> wrote:
>
> I'd like to be able to have optional values in a BeanEditForm linked
> bean represented as null, e.g. if they are of type Integer.
>
> I get the exception below.
>
> Should 'null' just coerce straight to null, unless it is trying to go
> to a primitive type?
>
> In TypeCoercerImpl, perhaps:
>
> // Treat null as void in terms of locating a coercion.
>
>          Class sourceType = input != null ? input.getClass() :
> void.class;
>
> Should be: (untested)
>
>         if (input == null)
>         {
>                 if (targetType.isPrimitive())
>                  {
>                      throw ...
>                  }
>                  else
>                  {
>                      return null;
>                  }
>          }
>
> Tom
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

Reply via email to