Hi,

Just curious... did someone already did a an application tool that can do
dynamic evaluation of the bean properties ?

Basically what I would like to do is:

#set ($properties = [ "X", "Y", "Z" ] )
#set ($result = $tool.evaluate($bean, $properties) )

so this is similar to:
#set ($result = [ $bean.X, $bean.Y, $bean.Z ] )

This would be particulary useful for a collection of entries, so that the
creation is factorized and that i can call a single macro to display the
list:

#macro (makeList $headings $properties $entries)
  <table>
    <tr>
      #foreach($heading in $headings)
        <th nowrap>$heading</th>
      #end
    </tr>
    #foreach($entry in $entries)
      <tr>
        #set ($result = $tool.evaluate($entry, $properties) )
        #foreach ($data in $result)
          <td>$data</td>
        #end
      </tr>
    #end
    </table>
#end

For now, I'm forced to pre-evaluate the data and to pass them to a macro as
follows:
#set ( $data = [] )
#foreach ($entry in $entries)
  #set ($elem = ["$entry.X", "$entry.Y", "$entry.Z"])
  #set ($dummy = $data.add($elem) )
#end
#makeList($headings $data)

Maybe there's a better way, but I can't figure out...

Thanks.

-- 
 St�phane Bailliez 
 Software Engineer, Paris - France 
 iMediation - http://www.imediation.com 
 Disclaimer: All the opinions expressed above are mine and not those from my
company. 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to