velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sriram Gopalan" <>
Subject Nested, cartesian loop of dynamic values
Date Thu, 11 May 2006 18:10:35 GMT
Hi, Here is my requirement. I have a list of function objects in java
that I can put into my velocity context. All these functions (methods)
take one parameter each. I also have this list of parameters that the
functions take. I need to be able to print the invoked return value of
these methods into my output file.
As an example, assume my functions are:
functions = {'getName', 'getAge','getSalary'...};
parameters = {'John','Joe','Jack','Mary'...}
and I want the output to be of the following format:
getName('John') = John Smith
getName('Joe') = Joe Doe
getAge('Jack') = 36
getSalary('Mary') = 30000
and so on. I hope my predicament is clear. The left hand side of the
output lines are easy ($, $ etc.) However,
the right hand side is dynamic and actually depends on the runtime
evaluated output value of invoking $function on $parameter. What are the
various ways in which I can do this? What would my template look like?
#foreach ($function in $functions)
    #foreach ($parameter in $parameters)
$'$') = ## ???? WHAT COMES HERE?
Thanks for the help in advance.
Sriram Gopalan

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message