Kbase 13181: VALIDATE Method in 7.3A and later (validation)
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
VALIDATE Method in 7.3A and later (validation)
The following enhancement was included in Version 7.3A and later in
response to request by our Version 6 customers. The motivation behind
this enhancement is to allow Version 6 customers to move their
UPDATE statement to event driven ENABLE, WAIT-FOR, ASSIGN:
A new method, VALIDATE, has been added for frame and field
level widgets. This method is used to fire any validation
associated with widgets within a particular frame. For field
level widget, querying the VALIDATE method executes the
validation and returns true if the validation was successful.
If the validation fails then it returns false and if the widget
is enabled and visible, the validation message is displayed and
focus is given to the widget. For frame level widgets, querying
the VALIDATE method causes validation to be executed on every
field in the frame. It returns true if all the fields pass their
validation, otherwise it returns false. If a field within a
particular frame does not pass its validation and the field is
visible and enabled, the validation message is displayed and focus
is given to that widget.
One of the main reasons the validate() method was implemented was to
give version 7 and 8 users the ability to validate all fields in the
frame and not just the ones that have been 'touched' by the user.
Using the validate() method on the frame will validate all of the
fields in the frame.
The validate() method can be used to invoke data dictionary validation
or the validation that is hardcoded in the form statement (see
example below).
Remember, however, that if you define dictionary validation for
certain fields, the validation will fire when you leave that field
after changing the value. This happens whether you use ENABLE ALL or
when you ENABLE field by field. Note that this will also only happen
when the leave event is actually fired for the field that the user
has 'touched'. If the user uses a mnemonic to choose a menu option or
a button or if the user hits return when there is a default button
on the window from the field in error the leave event will not fire
thus the data dictionary validation will not fire. If you do NOT
want data dictionary validation to fire when the user 'touches'
fields then you must use 'with no-validate' on your frame statement
but then this will prevent the VALIDATE method from working.
Here is an example of how the new VALIDATE method works:
def var i as int init -1.
def var b as char.
form i validate(i > 0, "Invalid i") b with frame x side-labels.
display i b with frame x.
enable i b with frame x.
on go of frame x
do:
message "Go Trigger executing".
if (not frame x:validate()) then
do:
message "Frame validation failed".
return no-apply.
end.
end.
wait-for go of frame x.
A version 8 example would be that you have a smartViewer with an
update panel. When the user copies or updates records but does not
'touch' all the fields, you may still want all the fields validated.
You would, in this case, create a local-assign-record procedure
in the viewer. The local-assign-record code to validate, say the
balance field, would look like this:
if (customer.balance:validate() in frame F-Main) then
/* dispatch standard adm method. */
run dispatch in this-procedure (input 'assign-record':U)
else return 'adm-error'.
Progress Software Technical Support Note # 13181