In our wiki, I have an Application I designed to be used to file Expense Reports. Ideally, I would like people to be able to click “Add Entry” and have it create a new page with an incrementing integer identifier rather than have them having to pause and come up with a (relatively meaningless) page title. The ID could be linked to our books and printed on the check as a permanent reference to that expense in the system.
Is there any way to make this happen today? Thanks!
Yes you can do that. It’s just that the app that AWM generates doesn’t support this. So you’ll need to modify the AWM-generated app or create a custom app.
Assume two users execute your code at the same time.
A gets start index 5 (B has not yet saved)
B get start index 5 (A has not yet saved)
A and B increment the index by one, meaning both have index 6 now.
B saves (document has index 6) and title ‘Doc 6’
A save (document has index 7) and title ‘Doc 6’
–> Page titles are no longer unique.
The timeframe to get into this situation is small, yet it exists.
And no, I’m not going to fix it. I hate fixing race conditions (because it is often really hard) when I have to, I don’t do it for fun.
It would be nice if that extension would be improved to support specifying multiple unique groups and not have just a single, common one, but it’s still something that might ensure you get a thread safe incremental number.
Yes you can do that. It’s just that the app that AWM generates doesn’t support this. So you’ll need to modify the AWM-generated app or create a custom app.
Hi, I am finally coming back around to this. How would l modify the AWM-generated app? Is that stored somewhere on disk when it is created, or stored in MySQL, or…? Not being a java person, the XML-with-embedded-code thing is pretty mysterious to me. I tried to look at the AWM code to see how it writes the application but couldn’t figure it out (in five minutes).
If you don’t have that time, you should consider that this feature doesn’t exist FTM and wait for it to be implemented in the future. This is is something we’d like to add but it’s not on the roadmap ATM. Note that you can also sponsor the development of it if you really need it, see https://www.xwiki.org/xwiki/bin/view/Main/Support#HProfessionalSupport . That’s a good way to contribute to XWiki too
Thank you for all of these links. I was having a hard time google searching to find this info, so having the direct links helps significantly. I will start digging in.
Hi – I am relatively new to Xwiki – but am having the same need – and hence issue to solve.
I found an example of AUTO INCREMENTING A PARAMETER under the TASK MANAGER APPLICATION example – the code is within in the SHEET page of the AWM code set. The number parameter of the TASKMANAGER (object) is AUTO INCREMENTED – each time a new TASK is created.
The HEADING for the parameter in the associated LIVE TABLE has been TRANSLATED TO “KEY”.
This might help you to find a way to solve your requirement.