Basic Customization > User Interface Customization > Presenting Information in the UI > UI Validation > Procedures – Post-select Validation
  
Procedures – Post-select Validation
Fortunately, the procedures for implementing post-select validation are much simpler than for pre-validation. There is really only one point where post-select validation can be implemented, and that is within a validator. It should also be noted that post-select validation applies only to actions. There is no concept of post-select validation for attributes or other UI components.
Creating a Validator
Creating a validator for post-select validation is exactly the same as creating a validator for pre-validation. SeeProcedure – Pre-Validation for details.
Implementing Post-Select Validation Methods
There are two post-select validation methods that can be implemented in a validator – one for single-select actions and one for multi-select actions. The respective names of these methods are validateSelectedAction() and validateSelectedMultiSelectAction(). If you’re adding validation for an action that could never be a multi-select action, you only need to implement the validateSelectedAction() method. If your action could possibly be a mutli-select action, you should implement both the validateSelectedAction() method and the validateSelectedMultiSelectAction() method.
The only real distinction between the two methods is in the method signatures. validateSelectedMultiSelectAction() returns a UIValidationResultSet, whereas validateSelectedAction() returns a single result.
public class MyValidator extends DefaultUIComponentValidator{
@Override
public UIValidationResultSet performFullPreValidation()
(UIValidationKey validationKey,
UIValidationCriteria validationCriteria, Locale
locale) throws WTException {
UIValidationResultSet resultSet =
UIValidationResult.newInstance);

// perform your business logic here
// if you want to enable the action/component, do this:
// resultSet.addResult(UIValidationResult.newInstance(validationKey
UIValidationStatus.ENABLED));
// if you want to disable the action/component, do this:
// resultSet.addResult(UIValidationResult.newInstance(validationKey,
UIValidationStatus.DISABLED));
// if you want to hide the action/component, do this:
// resultSet.addResult(UIValidationResult.newInstance(validationKey
UIValidationStatus.HIDDEN));
return resultSet;
}

@Override
public UIValidationResultSet validateSelectedMultiSelectAction
() (UIValidationKey validationKey,
UIValidationCriteria validationCriteria, Locale
locale) throws WTException {
UIValidationResultSet resultSet =
UIValidationResultSet.newInstance();

// perform your business logic here
// if you want to execute the action, do this:
//
resultSet.addResult(UIValidationResult.newInstance(validationKey,
//
UIValidationStatus.PERMITTED));
// // if you want to abort the action, do this:
//
resultSet.addResult(UIValidationResult.newInstance(validationKey,
// UIValidationStatus.DENIED));
// if you want to prompt the user for confirmation, do this:
//
resultSet.addResult(UIValidationResult.newInstance(validationKey,
//
UIValidationStatus. PROMPT_FOR_CONFIRMATION));

return resultSet;
}

}
How to Handle UIValidationStatus.PROMPT_FOR_CONFIRMATION
If your validator retuns PROMPT_FOR_CONFIRMATION status, it need to be configured special way by using PTC.validation.AJAXPostSelectValidation JavaScript function.
<action name="myAction" >
<command class="com.ptc.xxx" method="function" onClick="
PTC.validation.AJAXPostSelectValidation(event, validationKey)"/>
</action>
In this case, once you have made a/few selections and click myAction:
PTC.validation.AJAXPostSelectValidation function based on the provided validationKey executes post-select 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, another request will be send to the server to do the operation. There is inbuilt intelligence not to invoke your validator again for this request.