CIM uses validator objects to check user input for formatting or other errors. Validators return either true
or false
, and allow you to conditionally display messages or perform navigation commands.
Validators can be used at two levels in a script:
In a step, a validator can perform a check on some system state.
Note that using validators may mean that not all phases of the step execute. For example, if the outcome of a PRESTEP validator commands CIM to navigate to another step, later phases will never execute.
When a task collects input, a validator can check the input immediately.
For each validator, you need to specify:
The step phase in which validation takes place.
Commands to execute if the validator returns true (optional).
Commands to execute if the validator returns false (optional).
Step validators can be described in terms of the point at which they perform their check; this information is required in the phase
attribute of the validator
tag. The phases are:
PRESTEP
—Executed before processing a step starts.PREINPUT
—Executed after title and description UI rendered to user, but before any input collection elements are rendered.PRENAVIGATION
—Executed after UI input collection is complete and tasks are configured, but before navigation options are displayed to the user. at this point no tasks have been executed.POSTSTEP
—Executed after navigation chosen by user, does not execute if the user selects a navigation step that executes a command to move to another step.
To use a validator in a step, add the snippet below as a child of a <step>
element. Multiple validators can be added to a single step. They are processed in order depending on their phase
attribute.
<step> other xml... <validators> <validator id="DemoFileExistsValidator" phase="PRESTEP" > <if-true> <command type="DISPLAY_TEXT" value="file exists at ${DemoFileExistsValidator.absPathToFile}"/> <command type="GOTO_STEP" value="ThirdStep" /> </if-true> <if-false> <command type="DISPLAY_TEXT" value="file DOES NOT exist at ${DemoFileExistsValidator.absPathToFile}"/> <command type="GOTO_STEP" value="FirstStep" /> </if-false> </validator> </validators> ... other xml... </step>
To use a validator in a task, use the following XML:
<task id="CreateJBossAppServerInstanceTask" class="atg.cim.tasks.CreateJBossAppServerInstanceTask" <property name="serverInstanceName"> <value>pub_commerce</value> <input type="text"> <label>Enter a unique server instance name:</label> <validator id="NoWhiteSpaceValidator" phase="POSTINPUT"> <if-false> <command type="DISPLAY_TEXT" value="No white space allowed" /> <command type="REDO_INPUT" /> </if-false> </validator> </input> etc.
For an example, see the Example CIM Plugin section of this chapter, or review the files located at <ATG11dir>/CIM/plugins/base
in your Oracle Commerce Platform installation.