Hello,
I made a custom Validator and am using it on my applet.
My validator does something heavy calculation on its 'validate-value' method.
For example;
{define-class package MyValidator {inherits Validator}
{method public open {validate-value
controller:ValidationController,
target:ValueControl,
partial?:bool
}:#Visual
{sleep .1s} || something heavy calculation
{return {message my error!}}
}
}
I attach this validator with a TextField and put it with a CommandButton that shows a popup dialog.
{Dialog
{spaced-vbox
{TextField {validate-with {MyValidator}}},
{CommandButton
label = "OK",
{on Action do
{popup-message "OK"}
}
}
}
}
Edit a TextField's value (it's always marked as an error because of MyValidator) and
click a CommandButton without focusing out from the TextField.
Then two popup messages ("my error!" and "OK") are shown at the same time.
But in case attached validator has less validation time,
single message ("my error!") is shown and CommandButton's action isn't executed.
(please change the sleep time to 0.01s and try)
Shouldn't I rely on MyValidator to prevent firing CommandButton's action?
Are there any way to prevent it on errors exists?
I made a custom Validator and am using it on my applet.
My validator does something heavy calculation on its 'validate-value' method.
For example;
{define-class package MyValidator {inherits Validator}
{method public open {validate-value
controller:ValidationController,
target:ValueControl,
partial?:bool
}:#Visual
{sleep .1s} || something heavy calculation
{return {message my error!}}
}
}
I attach this validator with a TextField and put it with a CommandButton that shows a popup dialog.
{Dialog
{spaced-vbox
{TextField {validate-with {MyValidator}}},
{CommandButton
label = "OK",
{on Action do
{popup-message "OK"}
}
}
}
}
Edit a TextField's value (it's always marked as an error because of MyValidator) and
click a CommandButton without focusing out from the TextField.
Then two popup messages ("my error!" and "OK") are shown at the same time.
But in case attached validator has less validation time,
single message ("my error!") is shown and CommandButton's action isn't executed.
(please change the sleep time to 0.01s and try)
Shouldn't I rely on MyValidator to prevent firing CommandButton's action?
Are there any way to prevent it on errors exists?
Tags:
validation