Let me preface this by saying that I have almost zero
experience with Velocity so I don't know if I found a 
real bug or just a problem in my usage.

I am trying to display some portlets using the RowController.
I set the column sizes to be 30% and 70% but it was not 
setting the widths in the output table.  I added some debug 
comments to the WEB-INF/templates/vm/controllers/html/row.vm 
as follows:


<!-- Begin ROW Controller -->
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
#foreach ( $portlet in $portlets )
<!-- velocityCount = $velocityCount -->
<!-- sizes.size() = $sizes.size() -->
#if ($sizes.size() >= $velocityCount)
<!-- calc = ( $velocityCount-1 ) -->
<!-- width from calc = $!sizes.elementAt($velocityCount-1) -->
  #set ($width = $!sizes.elementAt($velocityCount-1))
#end
  <td valign="top" width="$!width">
    $!portlet.getContent($data)
  </td>
#end
</tr>
</table>
<!-- End ROW Controller -->

When I look at my displayed source for the page the debug
comments are

<!-- velocityCount = 1 -->
<!-- sizes.size() = 2 -->
<!-- calc = ( $velocityCount-1 ) -->
<!-- width from calc =  -->

and then 

<!-- velocityCount = 2 -->
<!-- sizes.size() = 2 -->
<!-- calc = ( $velocityCount-1 ) -->
<!-- width from calc =  -->


It looked like the Velocity code was not treating
the $velocityCount-1 as a number.  I added an 
intermeditate calculation as follows

#if ($sizes.size() >= $velocityCount)
  #set ($idx = $velocityCount - 1 )
  #set ($width = $!sizes.elementAt($idx))
#end

And this worked.  My question is this, is this a 
real bug or just some ignorance of Velocity on my
part? And if it is a bug do you want me to submit
a patch?

-- Steve Davis




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

Reply via email to