Wednesday, June 17, 2009

Xpages: Simple action groups and validation

I am looking for the best way to validate fields before a save, i could care less about what they are before i save, like in partial refreshes messing up because a field is empty.

I discovered that simple action groups are conditional, that gave me the thought to use them to validate the form before a save, not only could i validate whether Untitled-2it was empty but i should be able to validate if a value existed in a table, as in type ahead entries.  I could also validate the false statement and use the simple action confirm dialog to tell them what was wrong and that it did not save.

Is there a better way to do this?  I know you could do it client side, but then how do you stop your serverside script from running?


Steve Castledine said...

You might want to read this on validation:

The thing for you to note is switching off Client side validation.

Then if I am understanding your question correctly you are looking at using the "validation" options at field level. Look for section "validation" within each control (field etc).

This covers basic validation and you use in tandem with the error message controls (and occurs serverside but before save - when client side is switched off).

For more advanced validation, like looking up values in a table then you would add you own "custom validator" - under "All Properties" - "validators".

For an example download the xpages wiki from - look at custom control "prtContent" and field "subject".

Paul T. Calhoun said...

If the client side script returns 'false' then the server side script will not run. This allows for client side logic to be evaluated before the server-side script runs.

Mark Hughes said...

Thanks for the comments, one of the problems with your suggestion Steve is that type ahead fields try to validate after every keystoke, so it makes it impossible.

Post a Comment