Tuesday, 6 January 2015

Clearing Session State in APEX


As you develop your applications, you may find it useful to clear the cached value for specific items, all items on a page, all pages in an application, or the current user session. Clearing a cached value resets the value to null. The topics that follow offer specific examples of clearing session state.
Topics:

Clearing Cache by Item
Clearing cache for a single item resets the value of the item to null. For example, you might use this approach to make sure a specific item's value is null when a page is prepared for rendering.
The following example uses standard f?p syntax to clear the cache for an item. This example calls page 5 of application 100. Placing MY_ITEM in the ClearCache position of the f?p syntax resets the value of MY_ITEM to NULL.
f?p=100:5:&APP_SESSION.::NO:MY_ITEM
The following example resets the value of the items THE_EMPNO and THE_DEPTNO.
f?p=100:5:&APP_SESSION.::NO:THE_EMPNO,THE_DEPTNO
Clearing Cache by Page
Caching application items provides an effective way to maintain session state. However, there are occasions when you may want to clear the cache for all items on a page. For example, suppose you needed to clear all fields on a page when a user clicks a link that creates a new order. By clearing the cache for an entire page, you set the value of all items on the page to null.
Clearing Session Cache for Two Pages While Resetting Pagination
This example clears the session cache for two pages and resets pagination.
f?p=6000:6003:&APP_SESSION.::NO:RP,6004,6014


This example:
Runs page 6003 of application 6000 and uses the current session ID
Indicates to not show debug information (NO)
Clears all values maintained by the current session's cache for items of pages 6004 and 6014
Resets region pagination (RP) on page 6003 (the requested page)
Clearing Session Cache on a Page and Passing an Item Value
This example shows how to implement an update form. It clears existing information and sets the item's value (typically a primary key).
f?p=6000:6003:&APP_SESSION.::NO:6003:MY_ITEM:1234

This example:
Runs page 6003 of application 6000 and uses the current session ID
Indicates to not show debug information (NO)
Clears all values maintained by the current session's cache for items on page 6003
Sets the session state of an item called MY_ITEM to the value 1234
Clearing Session Cache on a Page and Passing Values to Multiple Items
This example is similar to the previous example, except it passes values to multiple items.
f?p=6000:6004:&APP_SESSION.::NO:6003:MY_ITEM1,MY_ITEM2,MY_ITEM3:1234,,5678

This example:
Runs page 6004 of application 6000 and uses the current session ID
Clears the current session's cache for items on page 6003
Indicates debug information should be hidden (NO)
Sets the value of MY_ITEM1 to 1234, sets the value of MY_ITEM2 to null (indicated by the comma used as placeholder), and sets the value of MY_ITEM3 to 5678

Clearing Cache for an Entire Application
You can clear an application's cache by using f?p syntax and creating a Clear Cache argument using the keyword APP. For example:
f?p=App:Page:Session::NO:APP

Note:
Resetting the cache for an entire application does not restore the application to a completely reset state. For example, if an application includes on-new instance computations or on-new instance processes, the Application Express engine runs these computations and processes when the application session is created. Then, it processes the clear cache request and displays the requested page.
To reset an application completely without a session ID (if no cookie is used to track the session ID), you must request it using a URL without a session ID, or by calling APEX_UTIL.CLEAR_APP_CACHE from another application. If the session ID is tracked using a cookie, you will need to logout to reset the state.
Clearing Cache for the Current User Session
Another approach to clearing an application's cache is to create a Clear Cache argument using the keyword SESSION. For example:
f?p=6000:6004:12507785108488427528::NO:SESSION
For Reference:



2 comments:

  1. Regards
    Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
    LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
    Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at training@oracleappstechnical.com | +91 - 9581017828.

    ReplyDelete
  2. Thanks for sharing great article about CXML Punchout.
    CXML Punchout

    ReplyDelete