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.
About this task
To
add a validation rule to the Management Center:
Procedure
- Open
WebSphere Commerce Developer and switch to the Enterprise Explorer
view.
- Complete one of the following steps:
- In the Enterprise Explorer view, expand , where Management_Center_component is
the name of the tool you want to customize. Validation rules are declared
as part of the object definition.
- In the Enterprise Explorer view, expand , where Management_Center_component is
the name of the tool you want to customize. Validation rules are declared
as part of the object definition.
- Identify the file that contains the object definition that
you want to add the validation rule to. Open the file and locate:
- the object definition class
- the objection definition
- 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>
<PropertyDefinition
displayName="${catalogResources.categoryCode_DisplayName}"
propertyName="identifier" type="string" required="true" maximumSize="254"/>
</PropertyDefinition>
- Complete one of the following steps:
Option |
Description |
Instantiate an instance of a class that extends lzx/commerce/foundation/restricted/Validator.lzx/wcfValidator as
a child element of an instance of
lzx/commerce/foundation/restricted/PropertyDefinition.lzx/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>
|
Declare a definition element that extends lzx/commerce/foundation/restricted/Validator.lzx/wcfValidator as
a child element of a PropertyDefinition element |
In the following example, the identifier property
definition is modified to include a custom validator that verifies
that the identifier does not contain spaces. The class name of the
custom validator is extNoSpacesValidator.<PropertyDefinition
displayName="${catalogResources.categoryCode_DisplayName}"
propertyName="identifier" type="string" required="true" maximumSize="254">
<NoSpacesValidator package="ext"/>
</PropertyDefinition>
|
- Complete one of the following steps:
Option |
Description |
Instantiate an instance of a class that extends
wcfValidator as a child element of an object definition (lzx/commerce/foundation/restricted/ObjectDefinition.lzx/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>
|
Declare a definition element that extends wcfValidator
as a child element of an object definition (lzx/commerce/foundation/restricted/ObjectDefinition.lzx/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. The class name of the validator is catOfferPriceMininmumQuantityUniquenessValidator. <PrimaryObjectDefinition
definitionName=
"catBaseCatalogGroupSKUPrimaryObjectDefinition"
baseDefinitionName="catBaseCatalogEntryPrimaryObjectDefinition"
isBaseDefinition="true"
objectGroups="CatalogEntry,SKUs,CatalogGroupSKUs"
idProperty="catentryId"
propertiesClass="catCatalogGroupSKUProperties"
displayName="${catalogResources.displayNameCategoryLevelSKU}"
newDisplayName="${catalogResources.displayNameNewCategoryLevelSKU}"
displayNameProperty="partnumber"
searchType="FindAllCatalogEntries"
helpLink="tasks/tpngen1s.htm">
...
<!--
Validator to check for duplicates in the offer price
minimum quantity values.
-->
<OfferPriceMinimumQuantityUniquenessValidator package="cat"/>
</PrimaryObjectDefinition>
|
What to do next
After you complete your customization:
Version |
Steps |
|
- Right-click LOBTools Project;
then click Build OpenLaszlo Project to produce
an updated ManagementCenter.swf file under the workspace_dir\LOBTools\WebContent
directory. This setting is the default environment setting.
- Test your changes by viewing
them in the Management Center, using this URL: https://hostname:8000/lobtools.
- Deploy
your changes to your production environment.
|
|
- Test your changes by viewing them in the Management Center, using
this URL: https://hostname:8000/lobtools.
- Deploy
your changes to your production environment.
|