> #set($count = 0)
> #foreach ($d in $xwiki.sort($dateList))
> <td>$d </td>
> <td> $pageList.indexOf[$count] $pageList.indexOf[$count] </td>
> #set($count = $count +1)
> just want to get the something from a list on the possition $count.
> Please tell me what i am doing that wrong?
Is $pageList a java.util.List instance? If so you should do
On 12/03/2009 07:42 PM, Bubulina wrote:
> out of curiosity, is it possible to make something, to write a line of code
> without the "#set(" but to not show the result on the page?
> for instance:
> - if i #set($list = $util.arrayList)
> and then
> $list.add($x) -just add x to the list, but in the same time shows "true"
> printed on the page. i would like to avoid this, and still keep the logic?
Velocity is just a wrapper for Real Java Code. $list is a java list, and
if you look at the API, you'll see that add returns a boolean. Velocity
is not smart, it does not classify methods in things that should print
something and things that only do stuff on the inside, so the result is
not important. Thus, calling any method that returns something other
than null will always result in printing the result. Here, calling means
simple calling, outside #if or #set or other directives.
Inside directives like #set and #if and macro calls, the result is not
printed, but used as a member of the directive. The trick for your
usecase is to do something like:
#set($discard = $list.add($x))
$discard is the generic variable name that we use inside XWiki code
especially for this kind of scenarios.