Data type handling in the web UI framework
A consistent method of data type handling is required to validate input boxes on the UI, for defining their entity XML files, and for other tasks. A data type is a data attribute that helps you set constraints on the data, such as acceptable values and what operations may be performed on that data.
- UI field validation (length, size, etc.)
When you add fields to the screen using the Extensibility Designer, the data types of the new fields help determine the display of the screen.
- UI component display (size, etc.)
Validation can be set up for user events like clicking a button or changing the cursor focus.
- The default implementation, which lets you continue using the data type handling implementation
of the Console JSP, or Swing UI implementations. Those implementations use the following data type
definition files:
- datatypes.xml (located at <INSTALL_DIR>/repository/datatypes)
- yfsdatatypemap.xml (located at <INSTALL_DIR>/repository/xapi/template/merged/resource)
You can customize this default implementation.
- Register the customized implementation of data handling. You
can use the web.xml file for this registration.
The following shows the out-of-the box configuration of the data type-related parameters in the web.xml file. To customize data type handling, you must replace the <param-value> entry with the classpath to the custom Java™ class, based on its location and package name.
<context-param> <param-name>scui-datatype-provider</param-name> <param-value> com.sterlingcommerce.ui.web.platform.dataType.SCUIDataTypeProvider </param-value> </context-param>
You can also register the customized implementation by making a Java call to the method SCUIDataTypeHelper.setDataTypeProvider.
The following shows an example of a package for a customized implementation:
package com.sterlingcommerce.ui.dataType; import java.util.Map; public interface ISCUIDataTypeProvider{ public Map getDataTypes(); public SCUIDataType getDataType(StringdataTypeName); public SCUIValidationResponse validate(StringdataTypeName, Stringvalue); publicbooleanisValid(StringdataTypeName,Stringvalue); publicvoidinit();
The following shows the guidelines for creating a data type using the SCUIDataType class that is used in the above package:
package com.sterlingcommerce.ui.dataType; public class SCUIDataType { /** Holds value of property name. */ private String name; /** Holds value of property type. */ private String type; /** Holds value of property size. */ private Integer size; /** Holds value of property decimalDigits. */ private Integer decimalDigits; /** Holds value of property negativeAllowed. */ private Boolean negativeAllowed; ....... public void setName(String name) { this.name = name; } public void setType(String type){ this.type = type; } public void setSize(int size){ this.size = new Integer(size); } public void setDecimalDigits(int decimalDigits) { this.decimalDigits = new Integer(decimalDigits); } public void setNegativeAllowed(boolean negativeAllowed){ this.negativeAllowed = new Boolean(negativeAllowed); } ....... public String getType(){ return this.type; } public boolean isNumeric() { return ("NUMBER".equalsIgnoreCase(getType())); } ........ }
To implement the customized Java code, build a jar file that contains the Java class, and then install the jar file using the install3rdparty.sh script.
To implement this customization, rebuild the EAR or WAR file as you did during the installation, and then deploy the application on the application server.