Joris,
There is the $xwiki.getUniquePageName("SpaceName" , "BasePageName")
which
allows to give you a page name not existing in XWiki.
It works in most cases, except if you generate the page name before the
save (for the form display) as you risk having twice the same name.
If you make this call just before the save, the duplicate risks are close
to zero.
As Edo has mentionned, a component would be needed to guarantee zero
possible duplication and/or to generate the page name for the edit form
(before saving). An even there there are some issues to support clustering.
We have been thinking about this and is part of our plan for 3.4/3.5 or
early 4.0.
Ludovic
2012/1/11 Joris Dirks <joris(a)user.stekje.nl>
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
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Ludovic Dubost
Founder and CEO
Blog:
http://blog.ludovic.org/
XWiki:
http://www.xwiki.com
Skype: ldubost GTalk: ldubost