velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: EscapeTool (and velocity-tool best practices)
Date Thu, 09 Dec 2004 18:20:37 GMT
On Thu, 9 Dec 2004 09:38:17 -0800, Will Glass-Husain <wglass@forio.com> wrote:
> I like this too.  It seems the most intuitive to me, particularly (as Nathan
> says) that the types of references are not explicit in Velocity.
> 
> To carry this further, I've proposed previously that the "==" operator have
> a fallback to toString equality.  In other words if the user does
> #if ($a == $b)
>
> If a and b are the same class, it should call equals(), but otherwise it
> should call toString.equals(). 

yeah, i'd almost forgotton about that proposal.  i liked it too,
especially because it's what i often end up doing manually  (e.g. #if(
"$!a" == "whatever" )  )

we should start up a "suggested feature/wishlist/roadmap" on the wiki
to gather these ideas in one place for easy overview of them.  not as
a replacement for bugzilla enhancement requests, but just as an easy
way to overview and cohesively write up the proposals with links to
the corresponding bugzilla RFE.

i haven't time to start this right now, so if someone else wants to
jump on it that's cool.  otherwise, i'll make a note to get this ball
rolling next week (when i'm done with finals!! yeah!).

> I've found this useful in JSTL, where I have
> a class that implements a singleton enumerated type.  In the JSTL I can say
>   <c:if test="${status == 'Active'}">
> 
> Even though status is actually a singleton class StatusActive with a
> toString 'Active'.

cool.

> Obviously, this would be a Velocity 2.0 change.  In the meantime having
> tools accept an Object parameter seems like a good solution.
> 
> WILL
> 
> 
> 
> 
> ----- Original Message -----
> From: "Nathan Bubna" <nbubna@gmail.com>
> To: "Velocity Users List" <velocity-user@jakarta.apache.org>
> Sent: Wednesday, December 08, 2004 5:02 PM
> Subject: Re: EscapeTool (and velocity-tool best practices)
> 
> > On Wed, 08 Dec 2004 15:21:34 -0500, Mike Kienenberger
> > <mkienenb@alaska.net> wrote:
> > ...
> >> In general, should Velocity tools that operate on a String operate on an
> >> Object instead and perform a object.toString() conversion first?  Or at
> >> least provide Object argument wrapper methods to call the String argument
> >> methods?
> > ...
> >
> > in general, yes.   the type of VTL references is a) not obvious, b)
> > mutable, and c) not as important as its string representation (since
> > we're working with the ''V" in MVC here).  as such, it's usually a
> > good idea to accept Objects and then attempt conversion to the needed
> > type.  if the param is null or the conversion can't be made, then it
> > is usually considered best to return null rather than throw
> > exceptions.
> >
> > these aren't hard and fast rules, but they've worked very well for me.
> > and they are what i prefer when it comes to contributions/patches.
> > ;-)
> >
> > ---------------------------------------------------------------------
> > 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