velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wgl...@forio.com>
Subject Re: POLL: null context attribute values
Date Fri, 16 Jan 2004 17:34:33 GMT
Makes sense to me, thanks.  next time I'll pay better attention :-)

WILL


----- Original Message ----- 
From: "Nathan Bubna" <nathan@esha.com>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Friday, January 16, 2004 9:25 AM
Subject: Re: POLL: null context attribute values


> Will Glass-Husain said:
> > Thanks Nathan for clearing that up.  But now after Claude's email I'm
> > confused again.
> >
> > Is there a difference between
> >
> > #if ($foo == null)
> >
> > and #if ($foo)  ?
>
> yes, for two reasons:
>
> - the first is invalid syntax.  Velocity has no "null" keyword (yet). :)
>
> - #if( $foo )  is equivalent to if( foo != null && foo != Boolean.FALSE )
in
> java.
>
> > The reason I ask is that many of my reference properties are database
> > fields, which may be null.  I check for null with:
> > if($record.fieldname)    field is not defined  #end
> > if(!$record.fieldname)    field is defined   #end
> >
> > In both cases, $record is defined, but the property fieldname may or may
not
> > be null.
> >
> > Will this still be the same with the new proposal?
>
> yes, this proposal will not change that.  it will change nothing in how
#if()
> itself behaves.  it only changes the behavior of #set() when the RHS
evaluates
> to null and #foreach() when the list/map/iterator/array contains null
values.
>
> Claude Brisson said:
> > > hum.... quite...
> > >
> > > #if( $foo )
> > >     $foo
> > > #elseif ($foo == false)
> > >      foo is false
> > > #else
> > >     foo is null
> > >  #end
> > >
> > > :-)
> > >
> > > CloD
> > >
> > > ----- Original Message ----- 
> > > From: "Nathan Bubna" <nathan@esha.com>
> > > To: "Velocity Users List" <velocity-user@jakarta.apache.org>
> > > Sent: Friday, January 16, 2004 5:47 PM
> > > Subject: Re: POLL: null context attribute values
> > >
> > >
> > > > Will Glass-Husain said:
> > > > > Question: Would the following syntax still work?
> > > > >
> > > > > #if($reference)
> > > > > $reference is defined
> > > > > #end
> > > >
> > > > yes.  in fact, it should work even better since:
> > > >
> > > > #foreach( $foo in $foos )
> > > >     #if( $foo ) $foo #else foo is null #end
> > > > #end
> > > >
> > > > should now work as intuition expects when $foos contains null
values,
> > and
> > > >
> > > > #set( $foo = "bar" )
> > > > #set( $foo = $tool.returnNull() )
> > > > #if( $foo ) $foo #else foo is null #end
> > > >
> > > > should display " foo is null " instead of " bar " (as it does
> > currently).
> > > >
> > > > make sense now?
> > > >
> > > > Nathan Bubna
> > > > nathan@esha.com
> > > >
> > > >
> > > > Geir Magnusson Jr said:
> > > > > > On Jan 16, 2004, at 7:15 AM, Christoph.Reck@dlr.de wrote:
> > > > > >
> > > > > > > Geir Magnusson Jr wrote:
> > > > > > >> On Jan 15, 2004, at 6:38 PM, Nathan Bubna wrote:
> > > > > > >>> lloyd said:
> > > > > > >>>
> > > > > > >>>> Nathan Bubna wrote:
> > > > > > >> [snip]
> > > > > > >>>> ...or just make it the toggle transitional
- deprecate it
for a
> > > > > > >>>> following release of velocity?
> > > > > > >>>
> > > > > > >>>
> > > > > > >>> sure, i'd suggest we could remove the toggle in
the next
release
> > > > > > >>> where we put
> > > > > > >>> aside BC concerns.  2.0 or whatever.
> > > > > > >>>
> > > > > > >>>> i can't imagine why anyone would want the old
(ie current)
> > > > > > >>>> behavior...
> > > > > > >>>
> > > > > > >>> well, then i've just barely got you beat there,
> > > > > > >>> because i can imagine precisely one:  backwards
compatibility!
> > ;)
> > > > > > >>>
> > > > > > >> I still wish I could recall the reason, because we
had
one.... :)
> > > > > > >
> > > > > > > The reason was due to the fact that a Hashtable does not
accept
> > > nulls,
> > > > > > > but Velocity uses a Map. Geir wanted the original vel
> > implementation
> > > > > > > to allow backing the context by whatever the application
> > developers
> > > > > > > desire - even a Hashtable.
> > > > > >
> > > > > > Thank you!  That's amazing that you can remember that.
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Now the proper BC proceeding should be:
> > > > > > >
> > > > > > > 1) The next relase of velocity sould have a new switch
that
> > defaults
> > > to
> > > > > > > the old form if not explicetely set in the properties.
A loud
> > > WARNING
> > > > > > > should be emitted into the logs (for whoever reads them)
that
> > tells
> > > > > > > to switch it to the new mode after upgrading/verifying
any
> > existing
> > > > > > > templates.
> > > > > > >
> > > > > > > 2) Then the release after that can default to the switch
the
> > "Right
> > > > > > > Way" (tm)
> > > > > > > and emit a WARNING if the switch has not explicetely set
in
the
> > > > > > > properties.
> > > > > > >
> > > > > >
> > > > > > That's not a bad plan.  Different than what I thought yesterday,
but
> > > > > > that would work.  We could do a release w/ the old way as
default,
> > w/
> > > > > > new way as switch to get the map, etc out there.  Then
immediately
> > > > > > uprev by 0.1 and have the new way as default, no other
difference.
> > And
> > > > > > then
> > > > > >
> > > > > > > 3) In velocity 2.0 the switch can be dropped altogether
(or an
> > ERROR
> > > > > > > can
> > > > > > > show if it still exits and is set to the old BC mode).
> > > > > > >
> > > > > > > For whatever these 0.02c are worth.
> > > > > >
> > > > > > In euro, not as much as it used to ...  :)
> > > > > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


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


Mime
View raw message