velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: Clean way to iterate over a distinct set of items?
Date Wed, 05 Oct 2005 13:13:40 GMT
Mike Kienenberger <mkienenb@gmail.com> writes:

IMHO that is not part of the view logic to find out the set of your
departments. It's part of the business logic. Write a small tool which 
returns a set of departments.

Doing that in Velocity (while it's probably doable) would be the wrong
place to do it.

(Java:)

Set deps = new HashSet();
for (Iterator it = employeeList.iterator(); it.hasNext(); )
{
    deps.add(it.next());
}

return deps;

	Best regards
		Henning

>I'm looking for a clean way to iterate over a distinct set of items.

>As an example. consider

>#foreach $employee in $employeeList

>where $employee.getDepartment() may or may not return a unique value.

>What I really want to iterate over is the unique set of departments in
>the employee list.

>Ideas?

>And this isn't really what I'm trying to do -- the real example is
>much more complicated, and there's no easy way to add a tool to the
>context so that I could have the equivalent of
>$tool.getUniqueDepartmentsForEmployeeList($employeeList).

>-Mike

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


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
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