With the discussion about whether or not to keep a separate generic tools directory, I thought it would be helpful to come up with a list of tools that would be nice to have. Many may have been mentioned on this or the users list and may already exist in some form that would allow them to be reused with little effort. With some of the tools listed below there's some overlap in functiontionality but the main thing I was trying to do is come up with some sort of list.
EmailTool - Send email using a template. Having this functionality can make a compelling reason to use Velocity since you can't really do this with JSP. Potentially, this could use an already configured VelocityEngine in VelocityViewServlet, and/or, it could be completely stand alone requiring it's own configured VelocityEngine instance and not be dependent on the servlet API. I've heard Turbine has such a tool.
IteratorTool - A wrapper class that converts various classes and interfaces into an iterator. Supports arbitrary starting and ending indexes, breaking out of the loop, provides the equivalent of $velocityCount without scoping problems, isOdd() and isEven() methods so you don't have to use a modulo, etc. FisherMill implements most of these features http://marc.theaimsgroup.com/?l=velocity-user&m=103176242630349&w=2. See also webwork.util.MakeIterator (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opensymphony/webwork/src/main/webwork/util/MakeIterator.java?rev=1.3&content-type=text/vnd.viewcvs-markup) , webwork.util.SubsetIteratorFilter (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opensymphony/webwork/src/main/webwork/util/SubsetIteratorFilter.java?rev=1.9&content-type=text/vnd.viewcvs-markup) and JSP taglib http://jakarta.apache.org/taglibs/sandbox/doc/iterators-doc/index.html.
IteratorMergeTool - A wrapper class that allows merging two (or more) iterators. Think an implementation has been posted here in the past year. See also webwork.util.MergeIteratorFilter (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opensymphony/webwork/src/main/webwork/util/MergeIteratorFilter.java?rev=1.7&content-type=text/vnd.viewcvs-markup).
IteratorSortTool - Sorts an iterator. Can use a default compartor or a user provided one. Several generic comparters could be provided. See webwork.util.SortIteratorFilter (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opensymphony/webwork/src/main/webwork/util/SortIteratorFilter.java?rev=1.8&content-type=text/vnd.viewcvs-markup).
IteratorBeanTool - Iterates over properties on a Bean.
#foreach ( $property in $beanIterater($person) )
Name: $property.name
Value: $property.value
Type: $property.type
#if ( $property.instanceof("String") )
$property.name is a String
#end
#endEvalTool - Evaluates a Velocity expression into the current output Writer or context varible.
MapTool - Converts an ArrayList of name=value pairs into a real Map. Until real Map support is added, this could be a useful way of specifying named parameters to methods, macros and directives.
JavaTool - helper methods for Java costructs that aren't supported natively through VTL.
- Array length
- instanceof
NumberTool - Parses a number specified as a String into a Float, Long, etc. Should also support parsing locale specific formatting. May also support formatting numbers as well or that could be a separate NumberFormatTool class.
StringTool - Formats and converts strings in various ways. See http://jakarta.apache.org/taglibs/doc/string-doc/index.html.
DateTimeTool - Formats and converts dates and times in various ways. See http://jakarta.apache.org/taglibs/doc/datetime-doc/index.html.
I18NTool - Formats Strings, Numbers, Currency, Percent, DateTime, Date and time in a locale specific manner. See http://jakarta.apache.org/taglibs/doc/i18n-doc/index.html.
Also, JSTL has a formatting tag "fmt." It may be worth looking at for ideas.
-Bill
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
