You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tom Davies <to...@exemail.com.au> on 2007/10/03 13:07:57 UTC

[T5] Null fields and BeanEditForm?

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] Null fields and BeanEditForm?

Posted by Marcelo Lotif <ml...@gmail.com>.
Just for record, I have a similar issue using null Date values inside the
Grid component using 5.0.7-SNAPSHOT. In my case, the value must be null and
when this happens i get an unintelligible tapestry exception saying that it
"Cannot format given Object as a Date" somewhere inside the tapestry code.

2007/10/25, Max Weissboeck <mw...@sphinx.at>:
>
>
> Is there already a solution to this, as I now have the very same problem
> (a
> Double value that must be null if the value is empty and not 0 - but if
> value is empty, an exception is thrown).
>
> Btw, I just startet to use T5 and I'm realy blown away! It's amazing how
> simple most things can be done! Very, very cool!
>
> Thanks, Max
>
>
> Howard Lewis Ship wrote:
> >
> > 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 <to...@exemail.com.au> 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: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Howard M. Lewis Ship
> > Partner and Senior Architect at Feature50
> >
> > Creator Apache Tapestry and Apache HiveMind
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-T5--Null-fields-and-BeanEditForm--tf4561146.html#a13407610
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Atenciosamente,
Marcelo Lotif

Re: [T5] Null fields and BeanEditForm?

Posted by Max Weissboeck <mw...@sphinx.at>.
Is there already a solution to this, as I now have the very same problem (a
Double value that must be null if the value is empty and not 0 - but if
value is empty, an exception is thrown).

Btw, I just startet to use T5 and I'm realy blown away! It's amazing how
simple most things can be done! Very, very cool!

Thanks, Max


Howard Lewis Ship wrote:
> 
> 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 <to...@exemail.com.au> 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Howard M. Lewis Ship
> Partner and Senior Architect at Feature50
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> 

-- 
View this message in context: http://www.nabble.com/-T5--Null-fields-and-BeanEditForm--tf4561146.html#a13407610
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T5] Null fields and BeanEditForm?

Posted by Howard Lewis Ship <hl...@gmail.com>.
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 <to...@exemail.com.au> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


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

Creator Apache Tapestry and Apache HiveMind