apex.page namespace

This namespace is used for all client-side page related functions of Oracle Application Express.

apex.page.cancelWarnOnUnsavedChanges

Call to remove the handler that checks for unsaved changes. This is useful to do before any kind of cancel operation where the user is intentionally choosing to loose the changes. It is not normally necessary to call this function because the declarative attribute Warn on Unsaved Changes with value Do Not Check will do it automatically. Adding the class js-ignoreChange to a link (anchor element) or button will cause this function to be called before the link or button action.

Parameters

None.

Example

The following sets up a handler on a custom cancel button that leaves the page without checking for changes.

apex.jQuery( "#custom-cancel-button" ).click( function() {
    apex.page.cancelWarnOnUnsavedChanges();
    apex.navigation.redirect( someUrl );
});

apex.page.confirm Signature 1

Displays a confirmation dialog showing a message, pMessage, and depending on user's choice, submits the page setting the request value to pRequest, or does not submit the page. Once the user chooses to submit the page the behavior is the same as for the apex.page.submit function. The shorter alias for this function apex.confirm with the same parameters can also be used.

Parameters

Table 38-45 apex.page.confirm Signature 1 Parameters

Name Type Description

pMessage

String

The confirmation message to display in the dialog.

pRequest

String

The request value.

Example

This example shows a confirmation dialog with the text 'Delete Department'. If the user chooses to proceed with the delete, the current page is submitted with a REQUEST value of 'DELETE'.

apex.page.confirm('Delete Department', 'DELETE');

or

apex.confirm('Delete Department', 'DELETE');

apex.page.confirm Signature 2

Displays a confirmation dialog showing a message,pMessage, and depending on user's choice, submits the page according to the options in pRequest, or does not submit the page. Once the user chooses to submit the page the behavior is the same as for the apex.page.submit function. The shorter alias for this function apex.confirm with the same parameters can also be used.

Parameters

Table 38-46 apex.page.confirm Signature 2 Parameters

Name Type Description

pMessage

String

The confirmation message to display in the dialog.

pOptions

Object

Options to control how the page is submitted. See “poptions properties” in apex.page.submit Signature 2.

Example

This example shows a confirmation message with the 'Save Department?' text. If the user chooses to proceed with the save, the page is submitted with a REQUEST value of 'SAVE' and 2 page item values are set, P1_DEPTNO to 10 and P1_EMPNO to 5433.

apex.page.confirm("Save Department?", {
  request:"SAVE",
  set:{"P1_DEPTNO":10, "P1_EMPNO":5433}
  });

or

apex.confirm("Save Department?", {
  request:"SAVE",
  set:{"P1_DEPTNO":10, "P1_EMPNO":5433}
  });

apex.page.submit Signature 1

This function submits the page with the Application Express REQUEST value set to pRequest. The shorter alias for this function apex.submit with the same parameters can also be used. Depending on the value of the page's Reload on Submit attribute the page is submitted using ajax or with a normal form submission post request.

This function triggers a “apexbeforepagesubmit” event on the apex.gPageContext$ which can be canceled. If canceled the page is not submitted.

Just before the page is submitted this function triggers a “apexpagesubmit” event on the apex.gPageContext$ which cannot be canceled.

Parameters

Table 38-47 apex.page.submit Signature 1 Parameters

Name Type Description

pRequest

String

The request value.

Example

Submits the current page with a REQUEST value of 'DELETE'.

apex.page.submit( 'DELETE' );

or

apex.submit( 'DELETE' );

apex.page.submit Signature 2

This function submits the page using the options specified in pOptions. The shorter alias for this function apex.submit with the same parameters can also be used. Depending on the value of the page's Reload on Submit attribute the page is submitted using ajax or with a normal form submission post request.

This function triggers a “apexbeforepagesubmit” event on the apex.gPageContext$ which can be canceled. If canceled the page is not submitted.

Just before the page is submitted this function triggers a “apexpagesubmit” event on the apex.gPageContext$ which cannot be canceled.

Parameters

Table 38-48 apex.page.submit Signature 2 Parameters

Name Type Description

pOptions

Object

Options to control how the page is submitted. See Table pOptions for each option property.

Table 38-49 pOptions properties

Name Description

request

The REQUEST value. For a confirm function the default is “Delete” for a submit function the default is null.

set

An object containing name/value pairs of items to set on the page prior to submission. The object properties are page item names and the item value is set to the property value. The default is to not set any page items.

showWait

If true a 'Wait Indicator' spinner is displayed, which can be useful when running long page operations. The defaults is false.

submitIfEnter

If you only want to submit when the ENTER key has been pressed, call apex.submit in the event callback and pass the event object as this parameter.

reloadOnSubmit

Override the Reload on Submit setting of the page. One of "A" (always) or "S" (success).

ignoreChange

If true (the default) and the warnOnUnsavedChanges feature is enabled no warning will be given if there are changes. If false and the warnOnUnsavedChanges feature is enabled and there are changes there will be a warning. If warnOnUnsavedChanges feature is disabled there is never a warning.

validate

If true check the validity of page items and models before submitting the page. If anything is not valid then show an alert dialog and don't submit the page. The default is false.

Returns

If the submitIfEnter option is specified, a Boolean value is returned. If the ENTER key is not pressed, true is returned and if the ENTER key was pressed false is returned. If submitIfEnter is not been specified, nothing is returned.

Example

This example submits the page with a REQUEST value of 'DELETE' and 2 page item values are set, P1_DEPTNO to 10 and P1_EMPNO to 5433 . During submit a wait icon is displayed as visual indicator for the user as well.

apex.page.submit({
    request:"DELETE",
    set:{"P1_DEPTNO":10, "P1_EMPNO":5433},
    showWait: true
});

or

apex.submit({
    request:"DELETE",
    set:{"P1_DEPTNO":10, "P1_EMPNO":5433},
    showWait: true
});

apex.page.validate

Check if page items and submittable Application Express models on the page are valid. Any errors are shown inline using apex.message.showErrors function.

Parameters

None.

Returns

true if the page is valid and false otherwise.

Example

The following example checks if the page is valid when a button with id checkButton is pressed.

apex.jQuery( "#checkButton" ).click( function() {
    if ( !apex.page.validate() ) {
        alert("Please correct errors");
    }
});

apex.page.isChanged

Return true if any page items or Application Express models on this page have changed since last being sent to the server. This will call the pExtraIsChanged function set in apex.page.warnOnUnsavedChanges if one was supplied and only if no other changes are found first.

Parameters

None.

Returns

true if any page items or Application Express models on the page have changed and false otherwise.

Example

The following example checks if the page is changed before performing some action.

If ( apex.page.isChanged() ) {
   // do something when the page has changed
} 

apex.page.warnOnUnsavedChanges

Initialize a handler that checks for unsaved changes anytime the page is about to unload. This is safe to call multiple times. The pMessage and pExtraIsChanged override any previous values. This function is called automatically when the page attribute Warn on Unsaved Changes is set to yes. The main reason to call this manually is to customize the parameters.

Parameters

Table 38-50 apex.page.warnOnUnsavedChanges

Name Type Description

pMessage

String

Optional message to display in the warning dialog when there are unsaved changes. If not given a default message is used.

Note: Not all browsers will show this message.

pExtraIsChanged

Function

Optional additional function to be called that checks if there are any unsaved changes. It should return true if there are unsaved changes and false otherwise. It is only called if there are no changes to any models or page items. This is useful if there are non-standard state-full inputs on the page that are not Application Express items and do not keep their state in an Application Express model. It allows writing a custom function to detect if those non-standard inputs have changed.

Example

The following example enables the warn on unsaved changes feature with a custom message.

apex.page.warnOnUnsavedChanges( "The employee record has been changed" );