Formatted Text Builder

 

In this topic ...

Quick Tips
Specifying Inputs

Related Topics ...

Overview: Creating Forms

Formatting and Translating Form Values

Use the Formatted Text builder to format values for display on a page. The Formatted text builder solves the problem of producing uniform formatting of dates and numbers. A typical use case for this builder is when you want to display a value as currency or as a date. We can also opt to make the displayed value editable. In this case, the value is presented within a text input box from which we can retrieve data.

This builder uses Java s MessageFormat and SimpleDateFormat classes to convert user input to appropriate formats. This conversion occurs at runtime, and the following conversion formats are supported:

Supported number formats include:

Currency         $987,654.00
Percentages      98%

Supported date input formats include:

E MMM dd yyyy hh:mma --  Thu Dec 13 1962 12:00AM

MMM dd yyyy hh:mma   --  Dec 13 1962 12:00AM

yyyy-MM-dd HH:mm:ss  --  1962-12-13 12:00:00

long                 --  48923332

Supported Date Output formats include:

E MMM dd yyyy hh:mma  --  Thu Dec 13 1962 12:00AM

MMM dd yyyy hh:mma    --  Dec 13 1962 12:00AM

yyyy-MM-dd HH:mm:ss   --  1962-12-13 12:00:00

 

Quick Tips

  • When working with dates, choose an input format. That format must be strictly adhered to when a date value is entered. If the date value is entered incorrectly, it will not be converted to the output format you have selected.

  • When working with percent, enter a decimal value to represent a percent less than 100%.

  • We can customize the input and output date formats to add more supported date formats.

 

Specifying Inputs

The Formatted Text builder takes the inputs described in the table below. For help on inputs common to many or all builders such as those in the Properties and HTML Attributes input groups, see "Using the Builder Call Editor."

Input name Description
Name Enter a name for this builder call. The designer tool displays this name in the builder call list.
Page Location Use the Page Location input to specify the page or pages on which this builder call will act.

See "Locating Control Builders on Pages" for detailed documentation about the Page Location input and page location syntax.

Type Select "Date" to display the value in one of the supported date formats.

Select "Number" to display the value in one of the supported numeric formats.

Editable Select "Yes" to allow the user to change the displayed value. The output will be presented within an input box. Selecting this parameter allows the Builder to retrieve data.

Select "No" to prevent  the user from changing the displayed value

Date Input Format If the value type is date, use this field to describe the date s input format. We can choose one of the following formats:

E MMM dd yyyy hh:mma       example:  Thu Dec 13 1962 12:00AM

MMM dd yyyy hh:mma         example:  Dec 13 1962 12:00AM

yyyy-MM-dd hh:mm:ss        example:  1962-12-13 12:00:00

long                       example:  48923332

See http://java.sun.com for more information on the Java SimpleDateFormat. The long input format is the milliseconds since January 1, 1970, 00:00:00 GMT.

Date Output Format If the value type is date, use this field to choose the dates desired output format.  You can choose one of the following formats:

E MMM dd yyyy hh:mma       example:  Thu Dec 13 1962 12:00AM

MMM dd yyyy hh:mma         example:  Dec 13 1962 12:00AM

yyyy-MM-dd hh:mm:ss        example:  1962-12-13 12:00:00

We can also type directly into this field any valid Java date format.

Number Output Format If value type is number, use this field to choose one of  the following number formats:

  • Currency - Displays number output in dollars and cents as follows: $12.34

  • Percent - Displays number output in percent as follows: 12.35%

We can also type directly into this field any valid Java number format.

Value The value entered here can be a date or a number.

This value can also be an indirect reference in the form:

${Variables/value}

Replace Tag Contents Enabled by default. If checked, prompts the builder to replace all the contents within the specified tag. Disable this check box if you want the builder to append its output to the existing text within the specified tag.
Handle Target Element If Add is selected, the builder adds its contents to the specified span tag. This is the default selection.

If Replace is selected, this parameter replaces the entire tag that it is being placed on and removes all the content within the specified span tag.

This parameter can be used in conjunction with the  Replace Tag Contents parameter to remove span tag contents while maintaining the actual span tag. We can use the Handle Target Element Replace option on its own to replace the span tag along with its contents.

For example:

If Add is selected and Replace Tag Contents is disabled:

<SPAN name="Default">Text1 is here:<input type="text" value="100%"/></SPAN><span>Found Tag1</span>

If Add is selected and Replace Tag Contents is enabled (the default settings):

<SPAN name="ReplaceContents"><input type="text" value="100%"/></SPAN><span>Found Tag1</span>

If Replace is selected:

<input type="text" value="100%"/>