Procedures – Post-Submit Validation
The procedures for implementing post-submit validation is much simpler than for pre-validation and similar to post-select validation. There is really only one point where post-submit validation can be implemented, and that is within a validator. It should also be noted that post-submit validation applies only to wizard steps and wizard submissions.
Creating a Validator
Creating a validator for post-submit validation is exactly the same as creating a validator for pre-validation. See
Procedure – Pre-Validation for details.
Implementing Post-Submit Validation Methods
There is only one post-submit validation method that can be implemented in a validator –The respective name of the method is validateFormSubmission(). This method is intended to be called after a wizard "next" or "finish" action is invoked, to determine whether or not the user-entered data is valid.
public class MyValidator extends DefaultUIComponentValidator{
@Override
public UIValidationResult validateFormSubmission
(UIValidationKey validationKey,
UIValidationCriteria validationCriteria, Locale
locale) throws WTException {
UIValidationResult result =
UIValidationResult.newInstance(validationKey,
UIValidationStatus.NOT_VALIDATED);
// perform your business logic here
// if you want to execute the action, do this:
// result = UIValidationResult.newInstance(validationKey,
UIValidationStatus.PERMITTED);
// if you want to abort the action, do this:
// result = UIValidationResult.newInstance(validationKey,
UIValidationStatus.DENIED);
// if you want to prompt the user for confirmation, do this:
// result = UIValidationResult.newInstance(validationKey,
//
UIValidationStatus.PROMPT_FOR_CONFIRMATION);
return result;
}
}
How to Handle UIValidationStatus.PROMPT_FOR_CONFIRMATION
If your validator retuns PROMPT_FOR_CONFIRMATION status, it needs to be specially configured.
• Option 1: Use your own custom ok/apply wizard button by using PTC.validation.AJAXValidateFormSubmission JavaScript function.
<action name="myOkButton" id="PJL_wizard_ok" >
<command class="" method="" windowType="page" url=" javascript:PTC.
validation.AJAXValidateFormAndSubmit(validationKey)"/>
</action>
In this case, once you click myOkButton:
◦ PTC.validation.AJAXValidateFormAndSubmit function based on the provided validationKey executes post-submit functions on the mapped validator.
◦ If the status is PROMPT_FOR_CONFIRMATION, confirmation pop-up will be shown and based on your selection further processing will happen.
◦ If you opt for “yes” for the confirmation or the status was PERMITTED, the form will be submitted. There is inbuilt intelligence not to invoke your validator again for this request.
• Option 2: Add your own user submit function in your jsp (invoked when the form is submitted) by using PTC.validation.AJAXValidateFormSubmission JavaScript function.
<script type="text/javascript">
setUserSubmitFunction (function () {return PTC.validation.
AJAXValidateFormSubmission(validationKey);});
</script>
In this case, once you have ok/finish wizard button :
◦ PTC.validation.AJAXValidateFormSubmission function based on the provided validationKey executes post-submit functions on the mapped validator.
◦ If the status is PROMPT_FOR_CONFIRMATION, confirmation pop-up will be shown and based on your selection further processing will happen.
◦ If you opt for “yes” for the confirmation or the status was PERMITTED, the ok/finish wizard button submits the form. There is inbuilt intelligence not to invoke your validator again for this request.
Parent topic