Basic Customization > User Interface Customization > Presenting Information in the UI > UI Validation > Solutions > Pre-Validation Sequence
  
Pre-Validation Sequence
The pre-validation sequence begins with the client infrastructure (typically, but not exclusively, the StandardNmActionService) sending a list of UI components to the validation service. The expectation is that for each of those UI components, the validation service will return a validation result indicating the display status for the UI component. Each UI component is represented by a validation key. It is also expected that the Client Infrastructure passes context (session, request, or form) data to the validation service inside of a validation criteria object.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
Once the validation service receives the validation request from the client infrastructure, the validation service iterates through each of the validation keys, and performs several tasks to determine the validation status for each of the keys.
The first such task that the validation service performs is to see whether or not a given validation key represents a component that should be hidden, based on the PTC solutions that are installed. This is accomplished by referencing a cache of invalid validation keys that is created when the validation service is first started. To create the cache, the validation service simply calls all registered solution groups and asks for a list of invalid validation keys from each of them, based on the installed solutions.
If the cache of invalid solution-based keys contains the current validation key, the validation service sets the component’s status to “hidden” and does not perform any additional validation on the component. Otherwise, if the cache of invalid solution-based keys does not contain the current validation key, the validation service continues with its pre-validation checks.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
2. For each validation key, the validation service performs a series of tasks to determine the validation status for that key. The tasks are executed in the following order:
a. Check to see if the validation key is in the list of invalid keys for the installed solution set.
The second pre-validation check performed by the validation service is to see whether or not the component is hidden or disabled by the role-based UI service. The role-based UI service was introduced in 8.0 as a way for admin users to configure the display of UI components based on a user’s role. With the introduction of the UI Validation Service in 9.0, the role-based UI service has become a special delegate of the UI Validation Service.
If the role-based UI service returns a status of “hidden” or “disabled”, the validation service sets the component’s status correspondingly and does not perform any additional validation on the component. Otherwise, if the role-based UI service returns an “enabled” status, the validation service continues with its pre-validation checks.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
2. For each validation key, the validation service performs a series of tasks to determine the validation status for that key. The tasks are executed in the following order:
a. Check to see if the validation key is in the list of invalid keys for the installed solution set.
b. Check to see if the role-based UI service was configured to disable or hide the component.
Assuming the role-based UI service says the component should be enabled, the validation service will next check to see if any filters are associated with the UI component.
To determine which filters should be applied to a UI component, the validation service references some additional cached data that is stored when the validation service is first started. The first cache referenced contains a list of all registered universal filters. When a filter is defined and registered as a universal filter, it is automatically applied to all UI components by default. If any universal filters are found in this cache, they are automatically added to the list of filters that will be applied to a given UI component.
Although universal filters are applied to all UI components by default, there is support for configuring actions to ignore individual universal filters. (Currently, there is no similar support available for configuring attributes to ignore universal filters, meaning that any universal filter will always be applied to all attributes.) If you want to configure an action to ignore a universal filter, you do so in the action’s definition in an actions.xml file. When the validation service is started, a second cache is created containing a map of actions and any universal filters they are configured to ignore. If an entry is found in this cache for a given action, the universal filters that are supposed to be ignored will be removed from the list of filters to be applied to the UI component.
Finally, the validation service references a third cache to determine any additional filters that should be applied to a UI component. This third cache is a map that associates actions with simple filters. A filter that is defined and registered as a simple filter must be explicitly associated with an action in order for it to be applied to any actions. (Currently, there is no support for associating a simple filter with an attribute.) If you want to configure an action to use a simple filter, you do so in the action’s definition in an actions.xml file. When the validation service is started, this third cache of actions and associated simple filters is created.
To summarize, the algorithm used by the validation service to determine which filters should be applied to a given UI component, you could use the following formula:
Filters per component = all universal filters – ignored universal filters + associated simple filters
Once the list of filters is established, the validation service calls each of the filters to determine the validation status for the UI component. Please note that the order in which the filters are called can not be guaranteed. If any of the filters return a validation status of “hidden” or “disabled”, the validation service sets the component’s status correspondingly and does not perform any additional validation on the component. Otherwise if all of the filters applied to a given UI component return an “enabled” status, the validation service continues with its pre-validation checks.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
2. For each validation key, the validation service performs a series of tasks to determine the validation status for that key. The tasks are executed in the following order:
a. Check to see if the validation key is in the list of invalid keys for the installed solution set.
b. Check to see if the role-based UI service was configured to disable or hide the component.
c. Check to see if any of the filters associated with the UI component indicate that the component should be disabled or hidden.
(See the diagram on the following page for additional details.)If none of the filters indicate that a UI component should be disabled or hidden, the final check performed by the validation service for a given UI component is to check to see if there is a validator associated with the UI component.
A validator is associated with a UI component by creating an entry in a service.properties.xconf file that links the action id (for actions) or the descriptor id (for attributes) to the class name of the validator class that should be used for that component.
If there is not a validator registered for the UI component, the component is enabled. Otherwise, if there is a validator associated with the UI component, the validation service calls that validator to get a validation status for the UI component.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
2. For each validation key, the validation service performs a series of tasks to determine the validation status for that key. The tasks are executed in the following order:
a. Check to see if the validation key is in the list of invalid keys for the installed solution set.
b. Check to see if the role-based UI service was configured to disable or hide the component.
c. Check to see if any of the filters associated with the UI component indicate that the component should be disabled or hidden.
d. Get the validation status from the validator, if there is one associated with the UI component.
(See the diagram on the following page for additional details.)At this point, the validation service has completed its validation checks for each UI component. If the client infrastructure passed a single UI component to the validation service to be pre-validated, the validation service will return a single validation result to the caller. If multiple UI components were passed to the validation service for pre-validation, the validation service will organize the validation results for each component into a validation result set, which contains one result per UI component. The validation result set is then returned to the caller.
Key
1. The Client Infrastructure calls the validation service, passing an action (represented by a validation key) corresponding to the page being rendered, and the context data (represented by a validation criteria instance).
2. For each validation key, the validation service performs a series of tasks to determine the validation status for that key. The tasks are executed in the following order:
a. Check to see if the validation key is in the list of invalid keys for the installed solution set.
b. Check to see if the role-based UI service was configured to disable or hide the component.
c. Check to see if any of the filters associated with the UI component indicate that the component should be disabled or hidden.
d. Get the validation status from the validator, if there is one associated with the UI component.
3. Return the validation result or validation result set to the client infrastructure.