Follow Us on Twitter

Saving user preferences in Oracle Webcenter

by Marcel Maas on July 10, 2012 · 5 comments

That’s the requirement that arose while working on a project with Webcenter Spaces last week. Of course there are a couple of ways to do so but we did not want to maintain our own preferences database. What we really wanted to do was save these preferences in the MDS because these user preferences would generate some personalized dashboards. Also we figured since the MDS should store user personalization and customization this was the right place to save this data.

However after searching heaven, earth and google I was almost ready to give up hope. I could use user personalization but this does not give you the amount of control I would like to have. My usecase was quite simple:

A user logs in to Webcenter Spaces. On his dashboard he can click a button to edit his preferences and get a list of checkboxes for choosing categories. These checkboxes define his preferences and should be saved in the MDS.

After a last search I came across the following package:

http://docs.oracle.com/cd/E21043_01/apirefs.1111/e10686/oracle/adf/share/prefs/package-summary.html

This seemed to be exactly what I needed. It gives you the possibility to save data to a map for only the current user. All this is persisted in the MDS. This means you can use this functionality for not only Webcenter but for any application using the Oracle MDS. An example:

// First create a PreferencesFactory
// This class automatically creates a connection to the MDS Server
ADFPreferencesFactory adfp = new ADFPreferencesFactory();
// Now save a preference by adding a value to the map on the userRoot (which saves the preference only for the logged in user)
adfp.userRoot().put("ShowNews", "Yes");

Now for retrieving the preference:

// Create the preferencesFactory again
ADFPreferencesFactory adfp = new ADFPreferencesFactory();
// Get the value of the preference "ShowNews"
// When no preference (key) "ShowNews" can be found, "No" is returned as value
String pref = adfp.userRoot().get("ShowNews", "No");
// pref now has the value "Yes"

As you can see the functionality is extremely simple. At the moment you put something on the map it is immediately persisted to the MDS. The UserPreferences package has some additional functionality but I will leave it to you to try that out. Just check the API reference.

Good luck!

Saving user preferences in Oracle Webcenter, 3.3 out of 5 based on 3 ratings
Ratings:
VN:F [1.9.22_1171]
Rating: 3.3/5 (3 votes cast)

5 comments on “Saving user preferences in Oracle Webcenter

  1. Pingback: The Data Center Journal Oracle VM Server Simplifies Virtualization

  2. Hi,
    I tried this on a plain ADF application and i am getting the following error.
    Am i missing anything.

    oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /oracle/adf/share/prefs/data/preferences.xml failed because source metadata store mapped to the namespace / BASE DEFAULT is read only

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. I am too getting the same exception on plain oracle ADF application.

    oracle.mds.exception.ReadOnlyStoreException: MDS-01273: The operation on the resource /oracle/adf/share/prefs/data/preferences.xml failed because source metadata store mapped to the namespace / BASE DEFAULT is read only

    Any Thought ??

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. As described in this blog, this works for Oracle WebCenter. If you want to use this API in plain ADF application, add namespace “/oracle/adf/share/prefs” as shown in following code snippet in your adf-config.xml.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Previous post:

Next post:

About Whitehorses
Company profile
Services
Technology

Whitehorses website

Home page
Whitebooks
Jobs

Follow us
Blog post RSS
Comment RSS
Twitter