You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Otto von Wachter <vo...@yahoo.com> on 2003/02/13 01:44:42 UTC

[contribution] ListTool

I'd like to contribute a new tool to the Velocity project.
I wrote this tool because I needed a simple way to generate
HTML dropdowns given Lists of business objects (I use it
with Torque)

Along with the tool there's a simple interface that for a
"value/description getter".

Here's an example of how this tool can be used:

  <p>select an address: </p>
  #set ($addrs = $addrPeer.doSelectAll())
  #set ($selAddr = $form.Address)
  #if (!$selAddr) #set($selAddr = "") #end 
  ##I do this because I'm having trouble passing a "null"
object in velocity
  $listTool.getDropdown($addrs, $addrPeer.AddressVDGetter,
$selAddr, "address")

This assumes that the peer class has a static instance of a
ValueDescriptionGetter (which can be implemented as an
anonymous class).

I hope this is a useful contribution :)

Regards,
Otto

Re: [contribution] ListTool

Posted by Nathan Bubna <na...@esha.com>.
Otto said:
> I'd like to contribute a new tool to the Velocity project.
> I wrote this tool because I needed a simple way to generate
> HTML dropdowns given Lists of business objects (I use it
> with Torque)

your willingness to contribute is appreciated, but generating HTML from
hardcoded java is a bit of a no-no around here.  :)

these sorts of things are far better done as Velocimacros IMHO.  (which, by
the way, we will hopefully begin collecting in the velocity-tools project to
form a core library of sorts)

Nathan Bubna
nathan@esha.com


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