Runtime tools : Channels components : HTML Channel : Tasks : Performing validation : Performing cross-field validation
  
Performing cross-field validation
Each business operation is responsible for cross-validating the data by doing the following:
Subclassing the DSEXValidate abstract class
Implementing the corresponding interface (OperationXValidate interface or ProcessorXValidate interface) by writing a xValidate method that returns String array
For operations, use the xValidate(Context) method. For processors, use the xValidate(transitionContext, transitionName) method. It is required to define the class name that is implementing the cross validation in the processor definition.
The result of the cross-validation method is an array of Strings (messages), which are stored in the operation context under the key of 'dse_ErrorMessages'. This context will be used later during the dynamic creation of the HTML.
Following is a cross-validation definition example for an operation:
<operation id=transferFunds context= transferFundsCtx
xValidation=com.ibm.btt.samples.html.transferFundsXVal>
Following is a cross-validation definition example for a process:
<processor id=financialInfo context=financialInfoCtx
xValidation=com.ibm.btt.samples.html.FinancialInfoXVal>
Following is an example of the data type definitions file:
<?xml version="1.0"?>
<dsetype.xml>
<!-- DSETYPE.XML-->
<!-- If property descriptors do not have "refType"s, they will point -->
<!-- to the type with thesame first name as themselves. -->
<!-- Exception is Property descriptors with id=typeDefault. They do -->
<!-- not need "refType" because they will point to the enclosing type. -->
<type id="String" implClass="com.ibm.btt.base.DataField">
<StringDescriptor id="typeDefault">
<stringConverter convTypes="default,host"
implClass="com.ibm.btt.base.types.ext.StringConverter"/>
</StringDescriptor>
</type>
<type id="Date" implClass="com.ibm.btt.base.DataField">
<DateDescriptor id="typeDefault" refType="Date">
<dateConverter convTypes="default"
implClass="com.ibm.btt.base.types.ext.DateConverter"
pattern="ddMmmyyy"/>
<dateConverter convTypes="xml"
implClass="com.ibm.btt.base.types.ext.DateConverter"
pattern="ddmmyy"/>
<dateValidator implClass="com.ibm.btt.base.types.ext.DateValidator"
mask="ddMmmyyyy"/>
</DateDescriptor>
</type>
<type id="AccountList" implClass="com.ibm.btt.base.IndexedCollection">
<ICollDescriptor id="typeDefault" refType="AccountList" size="0"/>
<IntegerDescriptor id="account number" refType="String"/>
</type>
<type id="Customer" implClass="com.ibm.btt.base.KeyedCollection"
keyBuilder="mySolemTest.FundsTransferKeyBuilder">
<KCollDescriptor id="typeDefault" refType="Customer"/>
<StringDescriptor id="customer name" refType="String" initialValue="Ralph"/>
<KCollDescriptor id="accounts" refType="AccountList" size="3"
description="list of accounts"/>
</type>
<type id="FundsTransfer" implClass="com.ibm.btt.base.KeyedCollection">
<KCollDescriptor id="typeDefault" refType="FundsTransfer"/>
<StringDescriptor id="accountFrom" refType="String" initialValue="2345"/>
<StringDescriptor id="accountTo" refType="String" initialValue="678589"/>
<DateDescriptor id="transactionDate" refType="Date">
<dateConverter convTypes="xml"
implClass="com.ibm.btt.base.types.ext.DateConverter" pattern="Mmmyy"/>
</DateDescriptor>
</type>
<type id="Float" implClass=com.ibm.btt.base.DataField">
<FloatDescriptor id="typeDefault">
<floatConverter convTypes="default"
implClass="com.ibm.btt.base.types.ext.FloatConverter"/>
<floatValidator implClass="com.ibm.btt.base.types.ext.FloatValidator"/>
</FloatDescriptor>
</type>
<type id="AccountTransferData" implClass="com.ibm.btt.base.KeyedCollection">
<KCollDescriptor id="typeDefault" refType="accountTransferData"/>
<StringDescriptor id="acctFrom" refType="String"/>
<StringDescriptor id="acctTo" refType="String"/>
<FloatDescriptor id="amount" refType="Float"/>
<StringDescriptor id="acctFromBalance" refType="String"/>
<StringDescriptor id="acctToBalance" refType="String"/>
</type>
</dsetype.xml>
Following is a context definition that refers to the AccountTransferData type definition:
<!---------------------------------------------------------------------------->
<! Account Transfer Operation Context... >
<!---------------------------------------------------------------------------->
<context id="AccountTransferCtx" type="oper" parent="htmlPageCtx">
<refType refId="AccountTransferData">
</refType>
<refService refId="theJournal" alias="Journal" type="cs"/>
<refService refId="theHost" alias="host" type="cs"/>
</context>
For an example of cross-field validation for simple operations, see the following in the HTML Sample Application:
accountTransferOp.xml (see the xVal attribute)
com.ibm.btt.samples.html.AccountTransferXVal class
<dse:valErrors renderMode="combo" /> in transfer.jsp
For an example of cross-field validation for navigation processes, see the following in the HTML Sample Application:
creditCardsProc.xml (see the xValidation attribute)
com.ibm.btt.samples.html.CreditCardApplXVal class
<dse:form action="/DSE_HtmlSampleAppl/Request" errorPage="creditApplMissingInfo.jsp" nextEventName="history"> in creditCardsWellcome.jsp
creditApplMissingInfo.jsp
Go up to
Performing validation