12 Adding Validation to an Integrated Excel Workbook

This chapter describes how to provide validation for your integrated Excel workbook

This chapter includes the following sections:

12.1 Introduction to Adding Validation to an Integrated Excel Workbook

You configure server-side and client-side validation for the Fusion web application and the integrated Excel workbook to make use of the validation options offered by the Oracle ADF Model Layer and Microsoft Excel. In addition to these validation options, you can make use of components in the Oracle ADF Desktop Integration module to return error messages from the Fusion web application, to provide status on the results of component actions, and to manage errors that may occur when data changes in an integrated Excel workbook conflict with data hosted by the Fusion web application.

12.2 Providing Server-Side Validation for an Integrated Excel Workbook

The ­Oracle ADF Desktop Integration module makes use of the validation rules that the Oracle ADF Model Layer sets for a binding's attributes. This means that data a user enters or edits in one of the Oracle ADF Desktop Integration components, such as the ADF Table component, can be validated against set rules and conditions in the Fusion web application. For general information about defining validation rules in Oracle ADF, see the "Defining Validation and Business Rules Declaratively" chapter in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

For information about adding ADF Model layer validation, see the "Adding ADF Model Layer Validation" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

To make sure that validation errors are reported correctly at runtime:

  • Make sure that the ApplyValidation attribute is set to True for any control bindings in your page definition file when you want to validate the data entered for these bindings.

    More information about the ApplyValidation attribute in page definition files can be found in the "pageNamePageDef.xml" section of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

12.3 Providing Client-Side Validation for an Integrated Excel Workbook

The Oracle ADF Desktop Integration module does not provide client-side validation. However, you can use Excel's data validation features to control the type of data or the values that end users enter into a cell. These features allow you to restrict data entry to a certain range of dates, limit choices by using a list, or make sure that only positive whole numbers are entered in a cell. For example, you could configure the Product Number column in the EditPriceList.xlsx workbook so that users can enter only whole numbers in the cells of this column.

If you apply custom validation to columns within an ADF Table component, the validation is propagated when the ADF Table component's columns are populated at runtime. Note, however, that the Oracle ADF Desktop Integration module overwrites at runtime any custom validation applied to columns that reference the TreeNodeList subcomponent at design time. This is because the Oracle ADF Desktop Integration module applies its own list-constraint validation, which is invoked at runtime.

Note:

Excel displays error messages when a validation fails; these error messages cannot be localized.

For more information about data validation in Excel, see Excel's documentation.

12.4 Error-Reporting in an Integrated Excel Workbook

The server that hosts the Fusion web application you integrate your Excel workbook with can return error messages to end users that provide feedback on the results of operations. The error messages returned can be one of a number of types: validation failures, conflict errors, deleted records, and so on.

Error-Reporting Using EL Expressions

To return messages to end users, you set an EL expression for the Value property of an ADF Output Text component. At runtime, the ADF Output Text component displays the error message to the end user if an error occurs.

The type of EL expression that you set for the Value property of the ADF Output Text component depends on whether you want to return error messages generated by action sets invoked on a worksheet or actions invoked by other components such as the ADF Table and ADF Read-only Table components. The following EL expression displays error messages which are returned during the invocation of an action set on a worksheet:

#{worksheet.errors}

At runtime, the previous error message is cleared (if one existed) when the action set starts invocation. If no errors occur during invocation, it remains blank. If an error occurs, the ADF Output Text component displays the error message.

An alternative approach to returning error messages generated by action sets invoked on a worksheet is to set #{worksheet.errors} as the value for an action set's Alert.FailureMessage property. This approach displays the generated error message in a dialog box.

Components such as the ADF Table and ADF Read-only Table components that have actions which interact with the Fusion web application can return error messages. Write the following EL expression for the Value property of the ADF Output Text component or for an action set's Alert.FailureMessage property:

#{components.componentID.errors} 

where componentID refers to the ID of the component (ADF Table or ADF Read-only Table component) that invokes the action.

The EditPriceList.xlsx file in the Master Price List module of the Fusion Order Demo application demonstrates how to return error messages generated by action sets invoked on a worksheet and by the actions of an ADF Table component. Figure 12-1 shows these EL expressions in design mode.

Figure 12-1 EL Expressions to Return Error Messages in an ADF Output Text Component

Shows EL expressions that return error messages

Error-Reporting Using Component Actions

The Oracle ADF Desktop Integration module provides actions that return errors generated by an ADF Table component or an integrated Excel worksheet. The action set in which you invoke one of these actions must include only one action. In general, action sets clear error labels and message lists when invoked. An action set that invokes one of the following actions returns error labels and message lists to the end user:

  • Worksheet's DisplayWorksheetErrors action

    You can configure a worksheet menu item to invoke this action. If you configure an ADF component (for example, ADF Output Text component) to invoke the DisplayWorksheetErrors action, there is no requirement to configure the same component's Value property to display the result of evaluating the #{worksheet.errors} expression described in the previous section on error-reporting using EL expressions.

    For more information about the Worksheet's DisplayWorksheetErrors action, see Section A.12, "Worksheet Actions and Properties".

  • ADF Table component's DisplayRowErrors action

    Invoke this action to return row-level failures to end users that occur in an ADF Table component when the ADF Table component invokes the following:

    • Upload

    • DeleteFlaggedRows

    • DoubleClickActionSet invoked from an ADF Table component column

    For more information about using this action, see Section 12.5, "Providing a Row-by-Row Status on an ADF Table Component".

  • ADF Table component's DisplayTableErrors action

    It is not intended that an ADF Table component column's DoubleClickActionSet invoke this action. Instead add this action to an action set that returns error messages to end users when failures occur during invocation of the action binding specified by an ADF Table component's BatchOptions.CommitBatchActionID property.

    For more information about ADF Table component actions, see Section A.8, "ADF Table Component Properties and Actions".

12.5 Providing a Row-by-Row Status on an ADF Table Component

The ADF Table component provides a mechanism to indicate to end users whether rows from the ADF Table component have been processed successfully or not after invocation of following ADF Table component actions:

  • DeleteFlaggedRows

  • Upload

  • DoubleClickActionSet invoked from an ADF Table component's column

The ADF Table component populates the _ADF_StatusColumn column with the status for each row following the invocation of the ADF Table component action. For example, it populates the _ADF_StatusColumn column with the upload status for each row following the invocation of the ADF Table component's Upload action.

Figure 12-2 shows a number of rows in an ADF Table component where values in rows have been changed as indicated by the upward pointing arrows in the Changed column. In the CostPrice column, a string value has been entered where a number value is expected.

Figure 12-2 ADF Table Component with Changed Rows Prior to Upload

DEG Component prior to upload

Figure 12-3 shows the same rows in the ADF Table component after invocation of the ADF Table component's Upload action. The ADF Table component populates the _ADF_StatusColumn column (labeled Status in this example at runtime) with the a message indicating whether the row updated successfully or not.

Figure 12-3 ADF Table Component with Changed Rows After Upload

DEG Component after upload

By default, the _ADF_StatusColumn column's DoubleClickActionSet is configured to invoke the ADF Table component's DisplayRowErrors action. When end users double-click a row in this column at runtime, the ADF Table component invokes the DisplayRowErrors action. This action displays a dialog box with a list of errors for that row if errors exist. If no errors exist, the dialog box displays a message to indicate that no errors occurred. Figure 12-4 shows the dialog box that appears if an end user double-clicks the cell in Figure 12-3 that displays Update failed in the Status column.

Figure 12-4 Dialog Displaying Row Error Message

Dialog displaying row error message

For more information about the _ADF_StatusColumn column, see Section 7.10, "Special Columns in the ADF Table Component".

12.6 Adding Detail to Error Messages in an Integrated Excel Workbook

You can configure your Fusion web application to report errors using a custom error handler if you want to provide more detail to the error messages displayed to end users in an integrated Excel workbook.

To implement this functionality, the custom error handler must override the getDetailedDisplayMessage method to return a DCErrorMessage object. At runtime, the Oracle ADF Desktop Integration module detects the custom error handler and invokes the getHtmlText method on the DCErrorMessage object. The Oracle ADF Desktop Integration module includes the HTML returned by the getHtmlText method in the error message list as detail.

For more information about creating a custom error handler, see the "Customizing Error Handling" section of the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

12.7 Handling Data Conflicts When Uploading Data from a Workbook

If one of your end users (John) makes changes to a row of data that he downloaded from a Fusion web application to an Excel workbook and another end user (Jane) in a different session modifies the same row in the Fusion web application after John downloads the row, John may encounter an error when he attempts to upload the modified row, as his changes conflict with those that Jane made. Depending on the configuration of your Fusion web application, John may receive RowInconsistentException type error messages. For information about how to configure your Fusion web application, see the "How to Protect Against Losing Simultaneously Updated Data" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

To resolve this conflict in the integrated Excel workbook, John needs to download the most recent version of data from the Fusion web application. However, invoking the ADF Table component's Download action causes the component to refresh all data that the component hosts in the Excel workbook. This may overwrite other changes that John made that do not generate conflict error messages. To resolve this scenario, you can expose the ADF Table component's DownloadFlaggedRows action. When invoked, this action downloads data only for the rows that the end user flags for download. Using this action, John can resolve the conflict issues and upload his modified data.

Chapter 15, "Using an Integrated Excel Workbook Across Multiple Web Sessions and in Disconnected Mode" provides information about using an integrated Excel workbook across multiple sessions. For information about flagging rows, see Section 7.9.2, "Row Flagging in an ADF Table Component". For information about invoking component actions, see Section 8.2.2, "How to Invoke Component Actions in an Action Set". For more information about the components that the ADF Table component supports, see Section A.8, "ADF Table Component Properties and Actions".

12.7.1 How to Configure a Workbook to Handle Data Conflicts When Uploading Data

You specify a row-specific attribute of the tree binding for the RowData.ChangeIndicatorAttribute property so as to determine whether a row has been modified by another user since the row was last downloaded by the ADF Table component.

To configure a workbook to handle data conflicts:

  1. Select the cell in the Excel worksheet that references the ADF Table component and click the property inspector button in the Oracle ADF Desktop Integration Designer to display the Edit Component: ADF Table dialog box.

  2. For the RowData.ChangeIndicatorAttribute property, specify the row-specific attribute of the tree binding that you use to determine whether a row has been modified by another user since the row was last downloaded by the ADF Table component in your integrated Excel workbook.

  3. Click OK.

12.7.2 What Happens at Runtime When You Configure a Workbook to Handle Data Conflicts

The ADF Table component caches the original value of the row-specific attribute of the tree binding that you specified as a value for RowData.ChangeIndicatorAttribute when it invokes the RowDownSync action. When the ADF Table component invokes the RowUpSync action, it checks if the value of the binding hosted by the Fusion web application and the original value cached by the ADF Table component differ. If they differ, it indicates data conflict, as changes have been made to the value of the binding hosted by the Fusion web application since the ADF Table component downloaded the value of the binding.