Display Formats

Display formats control the way the data is displayed, as opposed to the way it is stored.

For example, Boolean data is stored as 1 or 0, but you want to display it as True or False. To do so you would define a display format as DIS(True/False).

Display formats can be specified in the Field Layout property of a field, (or in a modeled field layout). You can also define display formats for component variables and global variables for use in display and string substitution.

You can control the display format in ProcScript using the $format function. This can be useful if you want to change the display format based on some kind of condition.

Defining Display Formats

To define a display format, use the following syntax:

DIS(Format)

For Numeric, Float, Date, Time, or Datetime, you can specify an NLS format:

DIS($NLS(NlsFormat))

Argument

Description

Format

Code or pattern that defines the formatting applied to the data.

NlsFormat

Keyword or display format pattern that defines the NLS formatting to be applied to the data; one of $NLS(NUMBER), $NLS(FLOAT) or $NLS(Format).

By default, if $NLS_LOCALE is specified in the assignment file, or in ProcScript (using $nlslocale and $webinfo("locale")), the language and styling conventions of the locale are applied. You can override this default behavior using $NLS(NlsFormat).

For more information, see NLS Display Formats.

When specifying a display format for a field, modeled field layout, or global variable, you can browse for a predefined format for data types Numeric, Float, Date, Time, or Datetime.

Default Data Display

By default, field data is displayed based on the data type and Database Interface.

If an NLS locale is also specified (for example, fr_CA), Uniface will apply the appropriate locale-based formats to Numeric, Float, Date, Time, and Datetime values.

You can set the NLS locale using the $NLS_LOCALE assignment setting or $nlslocale ProcScript function to a specific locale. This is used in desktop and server-based applications, and in server-side processing of dynamic server pages (DSPs).

For numeric and float data, conventions regarding plus, minus, digits, decimal separator, thousand separator, and currency symbols are applied. For dates, the names of days and months are in the specified language and the format follows the conventions for the country.

Specifying the correct interface and the locale is often the easiest way of formatting data for display. For more information, see Language and Locale.

Display Formats in DSPs

Dynamic server pages support a subset of the display formats that can be used in form components. In DSPs, JavaScript libraries handle browser-side processing, including display formatting. It is not always possible to map all Uniface display formats to JavaScript formats.

If your modeled entities are used in both desktop and web components, we recommend that you use only display formats that are supported by DSPs.

In DSPs, you can use the function $webinfo("locale") to set the locale for the client side of the DSP. To keep both the client-and server-side locale the same, you can use the following construction:

$webinfo("locale")= $nlslocale

For more information, see Display Formats for Numeric and Float Data in Dynamic Server Pages and Display Formats for Date and Time in Dynamic Server Pages.

Related Topics