1.10 Managing User Preferences

Developers can use preferences to store values for a specific Application Express user across distinct sessions. Once set, these preferences can be removed programmatically or manually. You can set user preferences by creating a page process, by the calculation of a preference Item Source Value, or programmatically by using a PL/SQL API.

1.10.1 Setting User Preferences

Developers can set user preferences within an application by creating a page process, creating a preference item, or programmatically.

1.10.1.1 Setting User Preferences by Creating a Page Process in Component View

To set user preference values by creating a page process:

  1. Navigate to the appropriate Page Definition. See "Viewing a Page in Component View" in Oracle Application Express Application Builder User's Guide.

  2. Access the Create Page Process Wizard. Under Processes, click the Create icon.

  3. For Process type, select User Preferences and click Next.

  4. For Process Attributes, specify a name, sequence, and processing point and click Next.

  5. For Type, select Reset Preferences (remove all preferences for current user) and click Next.

  6. Follow the on-screen instructions and click Create Process.

See Also:

"Creating Page Processes in Page Designer" in Oracle Application Express Application Builder User's Guide

1.10.1.2 Setting the Source of an Item Based on a User Preference

You can set the source of an item based on a user preference by defining the item source type as Preference.

To define the source of item based on a user preference:

  1. Navigate to the appropriate Page Definition. See "Viewing a Page in Component View" in Oracle Application Express Application Builder User's Guide.

  2. Under Items, click the Create icon.

  3. For Item Type, select Hidden and click Next.

  4. For Display Position and Name:

    1. Item Name - Enter an item name.

    2. Sequence - Specify the sequence for this component. The sequence determines the order of evaluation.

    3. Region - Select the region in which the item is placed.

    4. Click Next.

  5. For Settings:

    1. Value Protected - Specify whether the item is protected. Selecting Yes prevents the value from being manipulated when the page is posted.

    2. Click Next.

  6. For Source:

    Tip:

    To learn more about an attribute, see field-level Help.
    1. Source Used - Determines which value takes precedence, the cached value from session state or the item source value.

    2. Source Type - Select a source type for this item's value.

    3. Item Source Value - Enter the text corresponding to the source type for the item. For example, if the source type is QUERY, enter the SELECT statement here.

    4. Format Mask - Select or enter a format mask.

    5. Default Value - If the items source results in a null value, then set the item to this value. Reference the item default type attribute, since this attribute defines how the default value is interpreted.

    6. Default Value Type - Select how the default value is interpreted.

    7. Click Next.

  7. Click Create Item.

1.10.1.3 Setting User Preferences Programmatically

To set or reference user preferences programmatically, you must use a PL/SQL API. User-level caching is available programmatically. You can use the SET_PREFERENCE procedure to set a user level preference called NAMED_PREFERENCE. For example:

APEX_UTIL.SET_PREFERENCE(
 p_preference=>'NAMED_PREFERENCE',
 p_value =>:ITEM_NAME);

You can reference the value of a user preference using the function GET_PREFERENCE. For example:

NVL(APEX_UTIL.GET_PREFERENCE('NAMED_PREFERENCE'),15)

In the previous example, the preference would default to the value 15 if the preference contained no value.

See Also:

GET_PREFERENCE Function and SET_PREFERENCE Procedure in Oracle Application Express API Reference

1.10.2 Viewing Preferences by User

To view the preferences by user:

  1. Navigate to the Workspace Administration page. See "Accessing the Workspace Administration Page."

    The Workspace Administration home page appears.

  2. On the Administration page, click Manage Service.

  3. Under Manage Meta Data, click Session State.

  4. Click Preferences by User.

    The Preferences by User page appears.

  5. You can customize the appearance of the page using the Search bar at the top of the page.

1.10.3 Viewing Current User Preferences

To view current user preferences:

  1. Navigate to the Workspace Administration page. See "Accessing the Workspace Administration Page."

    The Workspace Administration home page appears.

  2. Click Manage Service.

  3. Under Manage Meta Data, click Session State.

  4. Click Current User Preferences.

    The Current user Preferences page appears.

    You can customize the appearance of the page using the Search bar at the top of the page.

1.10.4 Purging Preferences for a Specific User

You can purge preferences for a specific user on the Purge Preferences page.

To purge preferences for a specific user:

  1. Navigate to the Workspace Administration page. See "Accessing the Workspace Administration Page."

    The Workspace Administration home page appears.

  2. Click Manage Service.

  3. Under Manage Meta Data, click Session State.

  4. Click Purge Preferences by User.

    The Purge Preferences page appears.

  5. Select a specific user and click Report.

    A report appears at the bottom of the page.

  6. To purge the displayed user preferences, click Purge User Preferences.

1.10.5 Purging Preferences for the Current User

To purge preferences for the current user:

  1. Navigate to the Workspace Administration page. See "Accessing the Workspace Administration Page."

    The Workspace Administration home page appears.

  2. Click Manage Service.

  3. Under Manage Meta Data, click Session State.

  4. Click Purge Preferences for Current User.

    The Purge Preferences page appears.

  5. Select a user and click Report.

  6. To purge preferences, click Purge User Preferences.

1.10.6 Removing User Preferences Programmatically

To remove user preferences programmatically, you must use a PL/SQL API. You can use the REMOVE_PREFERENCE procedure to remove a user level preference called NAMED_PREFERENCE. For example:

APEX_UTIL.REMOVE_PREFERENCE(
p_preference=>'NAMED_PREFERENCE');

See Also:

"REMOVE_PREFERENCE" in Oracle Application Express API Reference

1.10.7 Resetting User Preferences Using a Page Process

You can reset user preferences by creating a page process and selecting the Reset Preferences process type.

To reset user preferences using a page process:

  1. Navigate to the appropriate Page Definition. See "Viewing a Page in Component View" in Oracle Application Express Application Builder User's Guide.

  2. Access the Create Page Process Wizard. Under Processes, click the Create icon.

  3. For Process type, select Clear Session State and click Next.

  4. For Process Attributes, specify a name, sequence, and processing point and click Next.

  5. For Type, select a page process type and click Next.

  6. Follow the on-screen instructions and click Create Process.

See Also:

"Creating Page Processes in Page Designer" in Oracle Application Express Application Builder User's Guide