De : Luc Dewavrin [mailto:[EMAIL PROTECTED]] > > Ok i have just realized my english was > not really understandable in my previous mail and my message > was not therefore really clear. > I'll try to make it short. > Is the syntax : > # foreach ($portlet in $portlets[0]) > correct to only get the portlets of the first column ? > I use this instruction in a velocity template file associated with a > multicolumn controller > and it doesn't work. $!portlet.getContent($data) gives me nothing. > > Of course i have tried the following syntax: > #foreach ( $column in $portlets) > # foreach ($portlet in $column) > and it works but i don't want to iterate through all the > columns and diplay > all the portlets! > > How can i only retrieve the portlets of a specific column > from the $portlets > object? >
The $portlets object in the context is of type List[] and as far as I know there's no notation in Velocity to directly access an array position using a range notation. You're left with 2 options: - write code to behave as a range access but through iteration ## We want the first column, ie $portlets[0] ## We assume that $velocityCount is starting at 1 as is the default #set ($target = 1) #foreach ( $column in $portlets ) #if ( $velocityCount == $target ) do something #end #end possibly defining this snippet as a macro - modify or subclass the MultiColumnControllerAction to change the type of the $portlets reference to an ArrayList of List, in which case you can use the notation: $portlets.0 or $portlets.get(0) -- Rapha�l Luta - [EMAIL PROTECTED] Jakarta Jetspeed - Enterprise Portal in Java http://jakarta.apache.org/jetspeed/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
