com.katharsys.pub.cx
Class DateValidation

java.lang.Object
  extended bycom.katharsys.pub.cx.DateValidation

public class DateValidation
extends java.lang.Object

The DateValidation CX provides validateDate to validate a date that the user has entered in a Text Feature and update the formatting of the date shown in the Text Feature.

Using the setDateFormat method, you can specify valid date formats or use the default formats of "MM/dd/yyyy" and "dd-MMM-yyyy". After date validation, the CX will update the value shown in the Text Feature to exactly correspond to the primary date format - the date format with the lowest index value.

Using the setDefaultCentury method, you can also specify a value to add to years entered with less than three digits. If this method is not used, 2000 will be added to any year that is less than 3 digits.

For example, if the default formats and century are used and the user enters "30-jun-08", the date will not match the primary format of "MM/dd/yyyy" but will match the second format of "dd-MMM-yyyy". It will be understood to be June 30, 0008. The default century will be added to change it to June 30, 2008. Then the date will be formatted according to the primary date format of "MM/dd/yyyy" such that the Text Feature will then show "06/30/2008".

This CX is designed to work with a single Text Feature at a time. Create a new CX rule for each Text Feature to be validated.

Rule Definition
Model Node Select the Text Feature to validate.
Java Class com.katharsys.pub.cx.DateValidation
Java Class Instantiation With Model Node Instance

Author:
Ken Truesdale, Katharsys LLC

Constructor Summary
DateValidation()
           
 
Method Summary
 void setDateFormat(int index, java.lang.String dfString)
          Adds a date format to the list of acceptable date formats.
 void setDefaultCentury(int defaultCentury)
          Sets the value to add to years of dates with less than three digits specified for the year.
 void validateDate(oracle.apps.cz.cio.TextFeature dateTextFeat)
          Executes the date validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateValidation

public DateValidation()
Method Detail

setDateFormat

public void setDateFormat(int index,
                          java.lang.String dfString)

Adds a date format to the list of acceptable date formats.

Only one date format can be added at a time with this method. Create a binding using this method once for each date format to be added.

Date formats are specified as string literals. The format for a date format string is specified by the Java class SimpleDateFormat. Note that some of the formatting provided by SimpleDateFormat is somewhat forgiving - for example even though the date format specifies a 4 digit year, it will accept 2 digits. (See the setDefaultCentury method for information on how to treat it as a 4 digit year.)

The other parameter for this method specifies the index order for date format. Order is important because formats can overlap in ability to parse. Assign lower index values to the formats you expect to be used more frequently. The specific value specified for index has no useful value other than in comparison to index values of other date formats.

The date format with the lowest index (the "first" format) will be also used as the format to update the Text Feature's value. For example, if a user enters a date that conforms to the date format in the 3rd index, it will be reformatted to conform to the date format in the 1st index.

If this method is not used at all, two default formats will be used. The first is "MM/dd/yyyy" and the second is "dd-MMM-yyyy". Therefore a value in the text feature entered as "1-dec-2000" will be updated to be "12/01/2000". If these default formats are what you want, there is no need to use this method at all. If you'd like to specify something other than these defaults, use this method for each date format you'll use. Note that if this method is used even once, neither default date format is used.

Event Binding
Event postCXInit
Scope Base Node
Method setDateFormat
Argument Binding(s)
Arg 1 Argument Type int
Argument Name index
Argument Specification Literal
Binding integer value representing relative order
Arg 2 Argument Type String
Argument Name dfString
Argument Specification Literal
Binding the date format String as defined by SimpleDateFormat


setDefaultCentury

public void setDefaultCentury(int defaultCentury)

Sets the value to add to years of dates with less than three digits specified for the year. In this way, if a user enters a date with a year of "09", this method will add "2000" to the year making the resulting year "2009". The addition is done mathematically, not with String addition. Therefore, when specifying the value to add, you should use the full 4 digit millennium and century (i.e. 1900, 2000).

If this method is not used, the default is to add "2000" to the year. Therefore, if this is the desired behavior, there is no need to use this method at all. Conversely, if you wish to remove the default, use this method and specify "0" as the value to add.

Note that this method technically sets both the millennium and the century but is named setDefaultCentury for simplicity.

Event Binding
Event postCXInit
Scope Base Node
Method setDefaultCentury
Argument Binding(s)
Arg 1 Argument Type int
Argument Name defaultCentury
Argument Specification Literal
Binding integer value to add to a year with less than 3 digits


validateDate

public void validateDate(oracle.apps.cz.cio.TextFeature dateTextFeat)

Executes the date validation.

The string value in the given Text Feature is checked to see which, if any, of the date formats defined by the setDateFormat method can parse it into a valid date. The first date format that can parse the string into a date is used to determine the date and then the resulting date is reformatted for display using the primary date format (see setDateFormat for info on primary date format). If no date format could parse the string, the Text Feature is cleared and the user is notified that the string was not a valid date format.

Event Binding
Event postValueChange
Scope Base Node
Method validateDate
Argument Binding(s)
Arg 1 Argument Type int
Argument Name dateTextFeat
Argument Specification Model Node
Binding the Text Feature that is also the Base Node



Copyright © 2010 Katharsys LLC. All Rights Reserved. Implementation-Version: 0.1-b46