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:
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
Geef jouw meningReactie plaatsen