Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Cascading validation of tabbed controls

Unread post by Ferenc Nagy »

I have recently posted "How the validation works on tabbed controls"http://discuss.visual-prolog.com/viewtopic.php?t=14326 on the other branch of this forum.
The tutorial
http://wiki.visual-prolog.com/index.php ... Validation
is a basic description of the validation.
I remember from somewhere that validation in executed on levels
0) min, max checks in integer and real controls
then by validate responders on
1) control
2) container (group box // tab page)
3) main form
levels.
Where is this cascade exactly described?

I have experimented by validation of tab controls.
Interesting:
The tabs containing more fields no to require OK buttons for click. Their validation is executed when the container holding the tab pages is validated when OK is clicked.

How can I validate only the contents only a single tab page regardless of the invalidity the other tab pages?
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The order is unspecified. Meaning that you cannot rely on any particular order.

You can see from the code however that in practice it is performed in a depth first order (from containerControl):

Code: Select all

clauses     validate() = Result :-         Control = getControl_nd(), %+             Result = Control:validate(),             Result = control::contentsInvalid(_, _, _),         !.       validate() = controlSupport::validate().
First each control is validated then the "parent" is validated.

It is not correct that integerControl and realControl are validated before other things, they are validated when they are returned by getControl_nd() just like any other control.
Regards Thomas Linder Puls
PDC
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Unread post by Ferenc Nagy »

It is not correct that integerControl and realControl are validated before other things, they are validated when they are returned by getControl_nd() just like any other control.
Let us suppose that I set the minimal value of an integer control to -10 and its maximal value to +10,
and I add an OnValidate event handler discarding the odd values.
What will be the cause of refusal of the value -1 and +13, respectively?
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The validate responders on a single control are executed in the order they are added to the control.

integerControl and realControl add their responders in the constructor, so it will be before you add your own responder.
Regards Thomas Linder Puls
PDC
Post Reply