WebSphere Lombardi Edition 7.2 > Modeling processes > Advanced modeling tasks > Build Coaches > Configure Coach controls


Control field and other formatting in Coaches

When building Coaches, you can add field formatting capability to Input Text and Output Text controls. The pre-defined field formatting available with Coaches includes standards such as US social security number, currency in dollars and Euros, and other standards. You can also use customized formats and apply formats to variables and localization resources that are bound to Coach controls. To learn more, see the following:

To learn how to... See...
Use the available predefined character formats Use pre-defined formats in Coach Controls
Use custom formatting characters in the Format field Use characters to apply custom numeric formatting
Update Lombardi configuration files to add custom formats Add custom format types
Use formatting with controls that are bound to variables Use formatting with variables
Apply formatting to a control that is bound to a localization resource Use formatting with language localization resources
Specify the alignment of buttons in a Button Group control Aligning buttons
Specify the horizontal and vertical alignment of check boxes and radio buttons Aligning check boxes and radio buttons


Use pre-defined formats in Coach Controls

The following procedure describes how to choose from the available predefined character formats:

  1. Open the service that contains the Coach that you want to work with and then click the Coaches tab.
  2. Click the Coach control for which you want to add formatting.
  3. Click the Presentation option in the properties.
  4. Under Widget Style, click the Select button next to the Format field and choose the format that you want:

    Option Example
    Currency: $ ###,###,###.## Enter the value 123456789, the value is formatted to $123,456,789.00
    Currency: ###,###,###.## € Enter the value 123456789, the value is formatted to 123,456,789.00€
    Currency: € ###,###,###.## Enter the value 123456789, the value is formatted to €123,456,789.00
    Integer: ###,###,### Enter the value 123456789, the value is formatted to 123,456,789
    Decimal: ###,###,###.## Enter the value 123456789, the value is formatted to 123,456,789.00
    US phone: (###) 000-0000 Enter the value 5555555555, the value is formatted to (555) 555-5555
    US SSN: 000-00-0000 Enter the value 123456789, the value is formatted to 123-45-6789

  5. Save your changes.

    When you run the service that contains the Coach, the values typed into the control are automatically formatted as shown in the preceding examples. If a user enters non-numeric characters, those characters are removed. If a user enters only non-numeric characters, no formatting is applied.


Use characters to apply custom numeric formatting

To apply numeric formatting to a control for integers and decimals, you are not required to select one of the pre-defined formats. Instead you can manually enter custom formatting characters into the Format field. For example, the # character acts as a digit placeholder. So if you type the following placeholders into the Format field in the Presentation properties for a control, you'll get the described results:

Format placeholder Results
## (placeholder for two digits) Since no decimal placeholder is specified, values entered into the control during run time are rounded up to the next integer. For example, if a user enters the value 34.2 into the control, the value is rounded up to 35.
##.# (placeholder for two digits and the tenths decimal position) For additional decimal positions typed in to the control during run time, decimals less than five are rounded down, and decimals greater than or equal to five are rounded up. For example, the value 34.24 would be rounded down to 34.2, and the value 34.57 would be rounded up to 34.6.

Follow these steps to use characters to apply custom numeric formatting:

  1. Open the service that contains the Coach that you want to work with and then click the Coaches tab.
  2. Click the Coach control for which you want to add formatting.
  3. Click the Presentation option in the properties.
  4. Under Widget Style, type the characters that you want to use as placeholders in the Format field. The following characters are available:

    Character Name Description
    # Digit placeholder A digit is copied into output. If there is no digit in this position, then nothing is stored in the output.
    0 Zero placeholder A digit is copied into output. If there is no digit in this position, a 0 is inserted into this position.
    ? Padding placeholder A digit is copied into output. If there is no digit in this position, a " " (space symbol) is inserted into this position.
    . Decimal separator The first . character (period) in the format string determines the location of the decimal separator in the formatted value. The actual character used as the decimal separator is determined by user locale settings.
    , Thousand separator The , character (comma) serves two purposes. First, if the format string contains a , character between two digit placeholders (0 or #) and to the left of the decimal point if one is present, then the output will have thousand separators inserted between each group of three digits to the left of the decimal separator. The actual character used as the decimal separator in the result string is determined by user locale settings. Second, if the format string contains one or more , characters immediately to the left of the decimal point, then the number will be divided by the number of , characters multiplied by 1000 before it is formatted. For example, the format string 0,, will represent 100 million as simply 100. Use of the , character to indicate scaling does not include thousand separators in the formatted number. Thus, to scale a number by 1 million and insert thousand separators you would use the format string: #,##0,,
    % Percentage The presence of a % character in a format string causes a number to be multiplied by 100 before it is formatted. The appropriate symbol is inserted into the number itself at the location where the % appears in the format string.
    E0 E+0 E-0 e0 e+0 e-0 Scientific notation If any of the strings E, E+, E-, e, e+ or e- are present in the format string and are followed immediately by at least one 0 character, then the number is formatted using scientific notation with an E or e inserted between the number and the exponent. The number of 0 characters following the scientific notation indicator determines the minimum number of digits to output for the exponent. The E+ and e+ formats indicate that a sign character (plus or minus) should always precede the exponent. The E, E-, e or e- formats indicate that a sign character should only precede negative exponents.
    ; Section separator The ; character (semicolon) is used to separate sections for positive, negative, and zero numbers in the format string.
    Other All other characters All other characters are copied to the result string as literals in the position where they appear.

  5. Save your changes.


Add custom format types

The predefined character formats for Input Text and Output Text controls are defined by the <formatting-templates> section in the [Lombardi_home]\process-center\config\system\99Local.xml file. To modify the formats or create additional formats, copy the <formatting-templates> section shown below and paste it into the [Lombardi_home]\process-center\config\100Custom.xml file. You can define additional formats as needed in the 100Custom.xml file.

<formatting-templates>
<formatting-template comment="Currency" template="$ ###,###,###.##" />
<formatting-template comment="Currency" template="###,###,###.## €" />
<formatting-template comment="Currency" template="€ ###,###,###.##" />
<formatting-template comment="Integer" template="###,###,###" />
<formatting-template comment="Decimal" template="###,###,###.##" />
<formatting-template comment="US phone" template="(###) 000-0000" />
<formatting-template comment="US SSN" template="000-00-0000" />
</formatting-templates>

If you add or modify formats in your development environment by altering settings for the Process Center server, be sure to make the same changes for each Process Server in your runtime environments.


Use formatting with variables

You can apply formatting to a Coach control that is bound to a variable. All input values are treated as numbers, even if they are bound to string variables.

If you create a service that includes a decimal variable named tw.local.amount with a default value of 251000.0 and you bind a Coach control to the tw.local.amount variable, you can still specify the format in which the value is displayed even though the value that the control displays during run time is determined by the value of the variable to which the control is bound. For example, if the US currency (dollars/cents) format is selected for the Coach control, when you run the service the Coach control is populated with the value of the variable, and the value is formatted to $251,000.00.


Use formatting with language localization resources

The following procedure illustrates how you can apply formatting to a Coach control that is bound to a localization resource. The localization resource for this example (named Localized Formats) includes a localization key named time, which contains two locales: Default Locale and Sweden. The value of Default Locale is ##:##:##, which is the standard format used to represent time in the majority of countries. The value of the Sweden locale is ##.##.##, which is the standard format for Swedish time:


  1. Open a service that includes several variables, and click the Variables tab.
  2. Click the Link Localization button and select the localization resource (in this example, Localized Formats) that you want to link to the service variables as a resource bundle.

  3. Create a Coach that includes an input text control named Time, and bind the control's formatting to the localization resource bundle and localization key by typing <#= tw.resource.LocalizedFormats.time #> into the Format field :

  4. Save your changes.

    You can test the binding by changing the interface language to svenska in Lombardi Process Portal preferences. Then run the BPD that contains the service and run the task from the Process Portal. When a you enter a 6-digit value such as 182400 into the Time field, the value should be formatted to 18.24.00, which conforms to the formatting that you specified.


Aligning buttons

When building Coaches, you can specify the alignment of buttons in a Button Group control.

  1. Open the service that contains the Coach that you want to work with and then click the Coaches tab.
  2. In the design area, click to select the Button Group control that you want to align.
  3. Click the Presentation option in the properties.
  4. Select the alignment (Left, Center, or Right) for the Button Group from the drop-down list.

  5. Click the Preview tab to see how the buttons will be displayed when you run the service.


Aligning check boxes and radio buttons

When building Coaches, you can specify the horizontal and vertical alignment of check boxes and radio buttons.

  1. Open the service that contains the Coach that you want to work with and then click the Coaches tab.
  2. In the design area, click to select the Dual List control that you want to align.
  3. Click the Presentation option in the properties.
  4. From the Widget Type drop-down list, select Multiple Check Boxes.
  5. From the Orientation drop-down list, select Vertical or Horizontal.
  6. Click the Preview tab to see how the buttons will be displayed when you run the service.

Single-selection List controls that use radio buttons provide the same alignment options in the Presentation properties.

Parent topic: Configure Coach controls

+

Search Tips   |   Advanced Search