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

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.

  2. 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.

  3. Identify the file that contains the object definition that to add the validation rule to. Open the file and locate the object definition class.

  4. Update the object definition with the new validation rule. There are three ways to add validation rules to an object definition.

    1. 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>
      

    2. 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> 
      

    3. 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:

  1. 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.

  2. Test the changes by viewing them in the Management Center, using this URL: https://hostname:8000/lobtools.

  3. Deploy your changes to the production environment.


Related concepts

Management Center shell

Management Center user interface


Related tasks

Changing validation logic


+

Search Tips   |   Advanced Search