Basic Customization > User Interface Customization > Customizing HTML Clients Using the Windchill JSP Framework > Adding Validation Logic for Actions and Properties > Implementation > Authoring a Validator Class > Implementing a validateSelectedAction Method
  
Implementing a validateSelectedAction Method
One of the methods you may choose to override in your Validator implementation is validateSelectedAction. As the method name suggests, this method is called by a client application wanting to know whether or not an action selected by a user from the UI can be performed. For example, A user selects “revise” from a list of actions for a document. Should the revise action proceed?
The method signature for validateSelectedAction looks like this:
public UIValidationResult validateSelectedAction (String validationKey,
UIValidationCriteria validationCriteria, Locale locale)
As you can see, the method takes three arguments:
1. A string indicating the key that was used by the client to identify the action being validated (think of this as the action name)
2. A UIValidationCriteria object (more on this in a second...), and
3. A Locale
The first and third arguments should be fairly self-explanatory. The UIValidationCriteria object is the validation criteria bean that was previously mentioned. It holds data that the client set and passed to the validation service (e.g., user, container, context object(s), etc.). The return type is UIValidationResult – whose attributes include a status indicating whether or not the action should be permitted.
Pseudo-code for a validateSelectedAction implementation would look like this:
import com.ptc.core.ui.validation.*;

public class MyValidator extends DefaultUIComponentValidator{

public UIValidationResult validateSelectedAction (String
a_key,
UIValidationCriteria a_criteria, Locale a_locale)
{
// get required info from UIValidationCriteria
WTContainerRef parentContainer =
a_criteria.getParentContainer();
WTReference contextObject = a_criteria.getContextObject();
WTPrincipalReference userRef = a_criteria.getUser();
// create status and message objects to pass back
UIValidationStatus status = null;
UIValidationFeedbackMsg msg = null;
// perform validation logic

if (we can allow this action to proceed){
status = UIValidationStatus.PERMITTED;
}
else{
status = UIValidationStatus.DENIED;
msg = new UIValidationMsg(localized text,
UIValidationMsgType.INFO)
}
// return a validation result with the calculated status
and message
return new UIValidationResult(a_key, contextObject,
status, msg);
}

}