Basic Customization > User Interface Customization > Presenting Information in the UI > UI Validation > Solutions > Procedure – Pre-Validation > Implementing Solution-Based Pre-Validation > Implementing a Solution Group
  
Implementing a Solution Group
Implementing a solution group class is very easy. All you need to do is create a class that implements the UIComponentSolutionGroup Interface, and in your class, implement the getInvalidInstallKeys() method. In that method, you check to see which solutions are installed, and return a list of validation keys representing actions or UI components that should never be available based on the installed solutions.
The class on the following page is an simple example of a solution group whose getInvalidInstallKeys() method checks to see if Pro/INTRALINK is installed. If Pro/I is installed, it returns a list of validation keys representing actions or components that should never be available.
package com.ptc.windchill.enterprise.myPackage;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import wt.log4j.LogR;
import wt.util.InstalledProperties;

public class MySolutionGroup implements UIComponentSolutionGroup
{
private static UIValidationKey listKey =
UIValidationKey.newInstance("list", "change");
private static UIValidationKey crKey =
UIValidationKey.newInstance("listChangeRequests", "change");
private static UIValidationKey cnKey =
UIValidationKey.newInstance("listChangeNotices", "change");
private static UIValidationKey viewKey =
UIValidationKey.newInstance("view", "change");
/*
* DEFINE ADDITIONAL ACTIONS AND UI COMPONENTS AS NEEDED
*/

private static Logger logger =
LogR.getLogger(MySolutionGroup.class.getName());

public List getInvalidInstallKeys()
{
if (logger.isDebugEnabled()){
logger.debug("ENTERING MySolutionGroup.getInvalidKeys");
}
ArrayList invalidList = new ArrayList();

// if PRO-I is installed, the following UI components are
not valid.
if
(InstalledProperties.isInstalled(InstalledProperties.PRO_I)){
invalidList.add(listKey);
invalidList.add(listKey);
invalidList.add(cnKey);
invalidList.add(viewKey);
}

/*
* ADD ADDITIONAL SOLUTION-BASED CHECKS AS NEEDED
*/

if (logger.isTraceEnabled()){
logger.trace("RETURNING " + (List)invalidList);
}
(logger.(trace("RETURNING " + (List)invalidList))){
logger.debug("EXITING MySolutionGroup.getInvalidKeys");
}
return invalidList;
}
}
If you’re wondering how to determine which values to include in the validation key factory methods, it depends on whether you’re creating a validation key for an action or an attribute. If you’re creating a validation key for an action, the first argument represents the action name (from *actions.xml) and the second argument represents the object type (from *actions.xml). For example, to create a validation key to represent the product action below, you would call UIValidationKey.newInstance(“product”, “navigation”);
<objecttype name="navigation" class=""
resourceBundle="com.ptc.core.ui.navigationRB">
<action name="product" renderType="GENERAL">
<command class="netmarkets"
method="servlet/Navigation?tab=product" windowType="page"/>
</action>
...
Constructing the ValidationKey
If you’re wondering how to determine which values to include in the validation key factory methods, it depends on whether you’re creating a validation key for an action, an action model, or an attribute.
If you are creating a validation key for an action, the first argument represents the action name (from *actions.xml) and the second argument represents the object type (from *actions.xml). For example, to create a validation key to represent the product action below, you would call UIValidationKey.newInstance(“product”, “navigation”);
<objecttype name="navigation" class=""
resourceBundle="com.ptc.core.ui.navigationRB">
<action name="product"
renderType="GENERAL">
<command class="netmarkets"
method="servlet/Navigation?tab=product"
windowType="page"/>
</action>
...
If you are creating a validation key for an action model, the first argument represents the action model name (from *actionModels.xml) and the seconfdargument represents the object type which is always “object”. For example, to create a validation key to represent the carambola_sub_model below you would call UIValidationKey.newInstance(“carambola_sub_model”, “object”);
<model name="carambola_sub_model">
<action name="ripe" type="carambola" />
<action name="grow" type="carambola" />
</model>
If you are creating a validation key for an attribute, simply use the descriptor ID used for that attribute in the Windchill client architecture. For example, to create a validation key for the attribute whose descriptor ID is “iteration”, you would call UIValidationKey.newInstance(“iteration”);