Develop > Presentation layer > Management Center framework > Customize the Management Center user interface > Customizing an existing Management Center tool > Changing validation logic
Add a validation rule
Add a validation rule where one does not exist in the Management Center user interface. For example, you can add a rule to validate that the business user has entered a value for a mandatory field. In addition to creating a validation rule on the client-side, you also need to create the validation logic on the server-side.
Tip: This task file provides the generic steps for adding a validation rule. For a tutorial on this topic, refer to Tutorial: Adding a validation rule in the Marketing tool.
To add a validation rule to the Management Center:
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- In the Project Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > commerce >Management_Center_component > objectDefinitions, where Management_Center_component is the name of the tool to customize. Validation rules are declared as part of the object definition.
- Identify the file that contains the object definition that to add the validation rule to. Open the file and locate the object definition class.
- Update the object definition with the new validation rule. There are three ways to add validation rules to an object definition.
- Specify values for the following property definition attributes: maximumSize, maxValue, minValue, required or type. For example, in the following property definition required is set to true and maximumSize is set to 254. This framework will display validation errors if the identifier property is blank or exceeds 254 characters.
<wcfPropertyDefinition displayName="${catalogResources.categoryCode_DisplayName.string}" propertyName="identifier" type="string" required="true" maximumSize="254"/> </wcfPropertyDefinition>
- Instantiate an instance of a class that extends wcfValidator as a child element of an instance of wcfPropertyDefinition. In the following example, the identifier property definition is modified to include a custom validator that verifies that the identifier does not contain spaces.
<wcfPropertyDefinition displayName="${catalogResources.categoryCode_DisplayName.string}" propertyName="identifier" type="string" required="true" maximumSize="254"> <extNoSpacesValidator/> </wcfPropertyDefinition>
- Instantiate an instance of a class that extends wcfValidator as a child element of an object definition (wcfObjectDefinition). This type of validator is called an object level validator. Object level validators are used to validate multiple property values or child objects. The following example demonstrates the declaration of an object level validator that ensures that there are no duplicate offer prices.
<class name="catBaseCatalogGroupSKUPrimaryObjectDefinition" extends="wcfPrimaryObjectDefinition" baseType="catBaseCatalogEntryPrimaryObjectDefinition" isBaseDefinition="true" objectGroups="CatalogEntry,SKUs,CatalogGroupSKUs" idProperty="catentryId" propertiesClass="catCatalogGroupSKUProperties" displayName="${catalogResources.displayNameCategoryLevelSKU.string}" newDisplayName="${catalogResources.displayNameNewCategoryLevelSKU.string}" displayNameProperty="partnumber" searchType="FindAllCatalogEntries" helpLink="tasks/tpngen1s.htm"> ... <!-- Validator to check for duplicates in the offer price minimum quantity values. --> <catOfferPriceMinimumQuantityUniquenessValidator /> </class>
What to do next
After you complete the customization:
- Right-click LOBTools Project; then click Build OpenLaszlo Project to produce an updated ManagementCenter.swf file under the workspace_dir\LOBTools\WebContent directory. This is the default environment setting.
- Test the changes by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.
- Deploy your changes to the production environment.
Related concepts
Management Center user interface
Related tasks