15.1 Understanding Page Computations

This section describes how to manage page computations in Page Designer and in Component View. You can use page computations to assign a value to an identified item when a page is submitted or displayed. You can also use application-level computations to assign values to items. Most page-level computations populate page items. In contrast, most application-level computations populate application items.

Topics:

15.1.1 About Page Computations

A page computation assigns a value to an identified item when a page is displayed or submitted (rendered and processed).You create a page computation by running the Create Page Computation Wizard. For each computation, specify the item for which you are creating the computation and a computation type.

15.1.2 Managing Page Computations in Page Designer

This section describes how to create page computations in Page Designer.

Tip:

Learn more about execution behavior in the case of a validation error.

Topics:

15.1.2.1 Creating a Page Computation in Page Designer

To create a page computation:

  1. Navigate to the appropriate page in Page Designer.
  2. In the Rendering tab, expand the Pre-Rendering or Post-Rendering node and locate where the computation should be.
  3. Right-click the location and select Create Computation.

    The Property Editor displays Computation attributes.

  4. To view all attributes in the Property Editor, click Show All .
  5. Edit the following attributes:
    1. Identification, Item Name - Enter the page or application item populated by this computation.
    2. Execution Options, Sequence - Specify the sequence for this computation. The sequence determines the order of execution.
    3. Execution Options, Point - Select at what point in page rendering or processing this computation is executed. The most typical computation point is After Submit.
    4. Computation, Type - Select a computation type. To view a list of options, see Help.

    Tip:

    To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the central pane.

    Next, define the action that to be performed if the event evaluates to True or False.

  6. Click Save.

15.1.2.2 Editing Page Computation Attributes in Page Designer

Once you create a computation, you can edit it on the Edit Page Computation page.

To edit a page computation:

  1. View the page to contain the item in Page Designer.
  2. In the Rendering tab, expand the Pre-Rendering or Post-Rendering node and select the computation.
  3. In Property Editor - Computation, edit the appropriate attributes.

    Tip:

    To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the center pane.

  4. Click Save.

15.1.2.3 About Editing the Computation Point and Source

You control when a computation executes using the Execution Options, Sequence and Execution Options, Point attributes. The Sequence attribute determines the order of evaluation. The Point attribute determines the point in page rendering or processing at which the computation executes. The most typical computation point is After Submit. For example, selecting On New Instance executes the computation when a new session (or instance) is generated.

After you specify the Sequence and Point, enter an expression or query under Computation to compute an item's value. In the event a computation fails, you can optionally define an error message in the Error Message attribute.

15.1.2.4 About Creating Conditional Computations

You can make a computation conditional by viewing the computation attributes in the Property Editor. Under Server-side Condition, edit the appropriate attributes.

15.1.3 Managing Page Computations in Legacy Component View

Developers can create and edit page computations in Component View.

Tip:

To learn more about execution behavior in the case of a validation error, see "What Happens When a Validation Fails?"

Topics:

15.1.3.1 Creating a Page Computation in Component View

A page computation assigns a value to an identified item when a page is displayed or submitted (rendered and processed).You create a page computation by running the Create Page Computation Wizard. For each computation, specify the item for which you are creating the computation and select a computation type.

To create a page computation:

  1. Navigate to the appropriate page. See "Viewing a Page in Legacy Component View."
  2. Access the Create Computation Wizard. Under Computations, click the Create icon.
  3. For Item Type, select the location where the computation executes and click Next. Location options include:
    1. Item on This Page
    2. Item on Another Page
    3. Application Level Item
  4. For Item:
    1. Compute Item - Select the item the computation updates.
    2. Sequence - Select the order of evaluation.
    3. Computation Point - Select the point at which the computation executes. The computation point On New Instance executes the computation when a new session (or instance) is generated.
    4. Computation Type - Select the method of computation you want to create.
    5. Click Next.
  5. In Computation, enter a computation that corresponds to the selected computation type and click Next.
  6. On Condition, you can choose to make the computation conditional. To make a computation conditional, make a selection from the Condition Type list and enter text in the expression fields.
  7. Click Create Computation.

15.1.3.2 Editing Page Computation Attributes in Component View

Once you create a computation, you can edit it on the Edit Page Computation page.

To edit a page computation:

  1. Navigate to the appropriate page. See "Viewing a Page in Legacy Component View."
  2. Access the Edit Page Computation page. Under Computations, select the computation name.

    The Edit Page Computation page appears.

  3. Edit the appropriate attributes.
  4. Click Apply Changes.

15.1.3.3 About Editing the Computation Point and Source

You control when a computation executes using the Sequence and Computation Point attributes on the Edit Page Computation page. The Sequence attribute determines the order of evaluation. The Computation Point attribute enables you to specify the point at which to execute the computation the item. For example, selecting On New Instance executes the computation when a new session (or instance) is generated.

After you specify the Sequence and Computation Point, under Source, enter an expression or query in the Computation field to compute an item's value. In the event a computation fails, you can optionally define an error message in the Computation Error Message field.

15.1.3.4 About Creating Conditional Computations

You can make a computation conditional by making a selection from the Condition Type list and entering text in the expression fields on the Edit Page Computation page.

15.1.4 Computation Points and Computation Syntax Example

A good example of using computations can be illustrated by a page containing form fields for entering phone numbers. In this example, the phone number is stored in one database column; however, the data entry form breaks the phone number into three components: area code, prefix, and line number. In this example, the page items are called P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER.

Next, suppose you need to combine the values stored in these items into a single string. You could accomplish this by using an After Submit computation and store the combined values in an item called P10_PHONE_NUMBER.

To create a computation to store the combined values of P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER in new items:

  1. Navigate to the appropriate page. See "Viewing a Page in Legacy Component View."
  2. Create an item named P10_PHONE_NUMBER to store the combined values of P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER.
  3. In Component view, under Computations, click the Create icon.
  4. For Item Location, select Item on this Page and click Next.
  5. For Computation Item, select P10_PHONE_NUMBER.
  6. For Sequence, select the order of evaluation.
  7. For Computation Type, you can create the following computation types:
    1. Static Assignment:
      • For Computation Type, select Static Assignment and click Next.

      • Enter the following computation:

        (&P10_AREA_CODE.) &P10_PREFIX.-&P10_LINE_NUMBER.
        
      • Click Next.

    2. PL/SQL Function Body:
      • For Computation Type, select PL/SQL Function Body and click Next.

      • Enter the following computation:

        DECLARE
        l_return_value  VARCHAR2(300) DEFAULT NULL;
        BEGIN
            l_return_value :=
        '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER;
        RETURN l_return_value;
        END;
        
      • Click Next.

    3. SQL Query (return colon separated value):
      • For Computation Type, select SQL Query (return colon separated value) and click Next.

      • Enter the following computation:

        SELECT '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER FROM DUAL
        
      • Click Next.

    4. PLSQL Expression:
      • For Computation Type, select PLSQL Expression and click Next.

      • Enter the following computation:

        '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER
        
      • Click Next.

  8. Click Create.