Hi Joris

I think there is no "good" solution in Velocity. I would do it in a
Java component. If you do not want to write a component you could use
Groovy alternatively. There you have the possibility of while.
If it has to be Velocity you could write a DB query which gets you all
your IssueXYZ documents. From those you can get the highest number and
increment your result.

Hope this helps
Edo

On Wed, Jan 11, 2012 at 3:36 PM, Joris Dirks <[email protected]> wrote:
> One of the use cases I have for my wiki is storing 'issues', where
> each issue should have a serial number consisting of year + subsequent
> number.
>
> I was thinking about a script like this, but one of the problems is:
> there is no 'while' function in Velocity.
>
> How would you create a form for this? Thanks for your ideas!
>
> Joris
>
> #set($space="Issues"}
> #set($template="AppSpace.IssueTemplate")
> #set($parent=$space.WebHome)
> #set($year= ${xwiki.formatDate($datetool.date, 'yyyy')})
> #set($partID="0"
> #set($genericID=$space"."$year)
>
> #while($xwiki.exists($space.$issueID'')
> {
> #set($partID=$partID+1)
> #set($issueID=$year"-"$partID)
> }
>
>  #if(!$xwiki.exists($issueID) && $xwiki.hasAccessLevel('edit',
> $context.user, $issueID))
>    $response.sendRedirect($xwiki.getURL($ID, 'inline',
> "template=$template}&parent=$parent"))
>    ## Stop processing, since we already sent a redirect.
>    #stop
>  #end
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to