On 02/03/2015 04:57 PM, Jason Clemons wrote:
bump...please help :)
> On Jan 30, 2015, at 10:50 AM, Jason Clemons <jason.clemons(a)live.com> wrote:
>
> 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.
>
There is no inherent magic in AppWithingMinutes created pages,
you can edit the generated pages the same as manually created ones.
(There is no guarantee these modifications will survive if you change the data structure
via AppWithinMinutes;
I remember there is a step in the wizard which asks you if the wizard can update
the sheets - this is the place where the wizard lets you know the changes get lost ;))
So, anyway, ou should have a space containing your "AppCode" ... and there
should be the "Sheet" page containing the code for viewing your items, which
includes the edit view.
If looking in the DocumentIndex for the page, it is one of these ending with Sheet ;) and
yes, it is hidden, so fix up your settings first.
There you can add a <input type="hidden" name="xvalidation"
value="AppName.ValidationGroovy" /> in the part
which has a #if($xcontext.action =='edit')
and then create your AppName.ValidationGroovy script "as advertised" in the
tutorial.
>
>
> 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..
>
There is also a DocumentCreatingEvent and DocumentUpdatingEvent
However listening to these event will not prevent the creation / update from happening, I
think;
i.e. you cannot prevent saving a document from an event listener, but only update
some values that need to be "automagically" set before saving.
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 !!! :)
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
hth
Clemens