Monday, November 24, 2014

Persisting to MDS Store using Programmatic API's in ADF

In last some of the posts regarding MDS, we saw how to achieve Personalizations and Seeded Customizations in Enterprise applications using Oracle ADF. There was explanation how to leverage Oracle ADF MDS framework for this purpose. Most of the personalization and customization is provided OOTB by the framework and just requires correct configurations and steps to achieve. These are declarative user customizations which allow to implicit save component changes done by the user.

But there are scenarios where some custom persistence is required to be saved to MDS Store. This means, that state of the components needs to be changes based on certain conditions. This explicit saving of state of components can be done using Java API provided by the framework.

Lets take an example for this post:
This example uses a ShowDetailFrame which is webcenter component. There is a button show/hide SDF which hides and shows the below SDF. Now this hide and show of SDF is being persisted in MDS Store. For now we will take File system based MDS Store. So for a particular user, when user performs show or hide of SDF, its state is stored in MDS and is presented to the user when it Logins next time into the application.

So when user clicks Hide/UnHide SDF button , action listener has to perform the logic of hide/unhide of SDF. More than this, the action listener needs to save the state of SDF (hide or show) to MDS Store. Now this is where it comes to the topic of this post. At this stage, it need some mechanism in action listener to perform this save of state of SDF to MDS Store.

This is done through API provided by MDS framework in ADF. It uses ChangeManager API from FacesContext to perform this.

Below is the page layout that I have described above.

Now lets see the implementation part. MDS is enabled and UserCC is added to adf-config.xml along with showDetailFrame as component.

By default showDetailFrame when selected from dropdown green button only has expansionMode and  contentStyle. Since we will be dealing with Hide/UnHide of SDF we need to add rendered property of SDF under showDetailFrame TagAttributes. Though there are no options in the Overview mode of adf-config.xml, attribute can be added in source mode. This is done as per below.

Now when Overview mode of adf-config.xml is again selected , one sees the new rendered attributed added.

By this way, one can add any attribute available with the component in the Tag Attributes just by adding the attribute in XML source of adf-config.xml under tagLib tag of the component.

Now since everything is set for our use case, lets see the page and managed bean where we need to code our magical action listener to save the state of SDF to MDS.

Below is the page how it which look like.

CustomMDSAppMB is managed bean. PannelCollection and showDetailFrame have their respective bindings in the bean. PannelCollection acts as a outer container which is being refreshed programmatically from actionlistener after show and hide is being done. Below is the code for actionlistener

This method gets called on click of hide/UnHide SDF and simply checks that if SDF is already rendered, set its rendered property as false else true.

Setting up of rendered property makes the SDF appear or disappear. After it the outer container(Panel Collection in this case) is being refreshed to make SDF appear or disappear.

So far so good. Now we achieved appear/disappear of SDF on button click. But the main thing is still pending. We need to save this state of SDF (weather appear or disappear which means redered property is true or false) in MDS Store for a particular user so that when user logs into the application next time he sees the changes done in last login.

Yes you guessed it right. persistAttributeChange method is doing the persistence of rendered attribute of showdetailframe to the MDS store.

Below is what persistAttributeChange method looks like.

The ChangeManager api provided by ADF is used to persist the attribute for a particular component to the MDS Store.

Now lets run the application. Login using Weblogic as user and click on hide/unhide SDF.

The result of click is as follows.

On click Hide/Unhide SDF, actionlistener gets fired and it changes the rendered property of SDF and save to MDS by calling persistAttributeChange method which uses ChangeManager API. One can see the changed xml in local file system.

Thats it, by using powerful MDS framework provided by ADF, developers can not only perform personalizations declarative/implicitly but also power of API which is provided by the framework can be used to do custom explicit personalizations.

Thanks !!


  1. Hi,

    Is there a way to copy an ADF saved search in the MDS programmatically and assign it to a difference user? Which will, in effect, share the saved search with another user? The MDS is database-based.


  2. Hi William,

    ADF Search can be saved in MDS, but i doubt that if it will be assigned to different user since the customization object needs to be based on user, roles or site. What I think is it may be possible if we give it a try by creating our own customization object. I will try and write a post on this.


  3. Hi,

    If i want to play with the af:query in respect to MDS, how do i achieve that. The tag configuration in adf-config file does not have query component in it.


  4. Hi Rohan,
    I have a question about saved search.
    My VO has some attributes which have default values which are exposed in the view criteria and thereby in the query panel. But when i create a saved search, my defaults are not getting persisted in the MDS.

    Have you come across this scenario?

  5. CIITN is located in Prime location in Noida having best connectivity via all modes of public transport. CIITN offer both weekend and weekdays courses to facilitate Hadoop aspirants. Among all Hadoop Training Institute in Noida , CIITN's Big Data and Hadoop Certification course is designed to prepare you to match all required knowledge for real time job assignment in the Big Data world with top level companies. CIITN puts more focus in project based training and facilitated with Hadoop 2.7 with Cloud Lab—a cloud-based Hadoop environment lab setup for hands-on experience.

    CIITNOIDA is the good choice for Big Data Hadoop Training in NOIDA in the final year. I have also completed my summer training from here. It provides high quality Hadoop training with Live projects. The best thing about CIITNOIDA is its experienced trainers and updated course content. They even provide you placement guidance and have their own development cell. You can attend their free demo class and then decide.

    Hadoop Training in Noida
    Big Data Hadoop Training in Noida