Hello all,
I'm hoping someone can give me a suggestion to save my skin. When I was
brand new to xwiki I quickly created an application for "ticketing" using
AppWithinMinutes because it seemed like the easiest way for a newbie to
create an application. In doing so I created a form which had several
controls on it (e.g.. around 20 or so). In order to maintain business logic
I wrote EXTENSIVE JavaScript which enforces business rules and prevents a
save (basically cancelling the postback through JavaScript) if they aren't
met. Admittedly this isn't that great of a solution as now I'm having
problems with JavaScript failures (mostly with other libraries being loaded
with xwiki which prevents my JavaScript from running) which then allow the
pages to be saved despite validation failures.
What I'm hoping is that there is some way to "shim" some server side code
in
using an event listener, or some sort of "before save" event in velocity or
groovy that can evaluate the submitted page and prevent a save if the
business logic rules are broken.
I don't really have the luxury of re-writing or refactoring the solution
I've written because it's in production at this point and works 95% of the
time, but I definitely need to do more in relation to validation since
broken rules cause downstream impacts to other applications relying on clean
data.
So, any help is GREATLY appreciated. I have seen this
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+valid
ation+and+tooltips and reviewed it, but I can't really figure out how I
would use it with an existing page or with AppWithinMinutes.
Also, I already have an event listener configured which does some stuff that
I might be able to use for this purpose.. but I think those events
(DocumentCreatedEvent() and DocumentUpdatedEvent()) happens AFTER the save
and I haven't really been able to find a way to "block" the save if it does
happen before anyway..
I would need to invoke validation on save and update of documents too.. I'm
hoping there might be some way of adding code to the AppWithinMinutes
generated page that can do some post save validation and stop the save if it
fails.
So help !!! :)