icon-arrow icon-check icon-mail icon-phone icon-facebook icon-linkedin icon-youtube icon-twitter icon-cheveron icon-download icon-instagram play close close icon-arrow-uturn icon-calendar icon-clock icon-search icon-chevron-process icon-skills icon-knowledge icon-kite icon-education icon-languages icon-tools icon-experience icon-coffee-cup
Werken bij Integration & Application Talents
Blog 10/07/2012

Saving user preferences in Oracle Webcenter

User preferences

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!

Overzicht blogs

Geen reacties

Geef jouw mening

Reactie plaatsen

Reactie toevoegen

Jouw e-mailadres wordt niet openbaar gemaakt.

Geen HTML

  • Geen HTML toegestaan.
  • Regels en alinea's worden automatisch gesplitst.
  • Web- en e-mailadressen worden automatisch naar links omgezet.

Wil je deel uitmaken van een groep gedreven en ambitieuze experts? Stuur ons jouw cv!