Tuesday 29 July 2014

seeded Metadata Services (MDS) in ADF - environment preparation, proof of concept

It is time to make the proof of concept that'll show if it really works. As it has been mentioned in the introduction, seeded customizations are divided to layers and values. One layer groups one or more values, for example you can define layer for each departament and user roles for its values. For that example i'll provide only one myCustLayer with two values: first, second.

Please create SeededMdsDemoApp basing on Fusion Web Application template. Go through wizard without any changes.


Right click on Model project and remove it.


Add new generic project named CcProject.




Right click on it, go to Project Properties. Select Libraries and Classpath and click on Add Library button. Select MDS Runtime and click OK to confirm changes.



 
Create new Java class that extends oracle.mds.cust.CustomizationClass.



As you can see, you have got three methods to implement.


Right click on CcProject in Application Navigator section, select Deploy and New Deployment Profile. Please use ADF Library JAR file.


Confirm all and deploy project to JAR file using the defined profile.


Now the tricky part. JDeveloper needs to have definition of the layer in its own configuration. The reason that customization class is in separate project is to put JAR file to JDev's classpath. Please put it to <jdeveloper_home>\jdev\lib\patches. The layers must be visible for the IDE, therefore please open <jdeveloper_home>\jdev\CustomizationLayerValues.xml file and add this code:

  <cust-layer name="myCustLayer" id-prefix="mcl">
    <cust-layer-value value="first" display-name="layer one" id-prefix="1"/>
    <cust-layer-value value="second" display-name="layer two" id-prefix="2"/>
  </cust-layer>

In Application Navigator right click on ViewController project, pick Project Properties and go to Dependencies. Please remove Model dependency and add dependency to CcProject.


MDS must be enabled for the project, please select ADF View node, and check Enable Seeded Customizations option.


In Application Navigator please expand Application Resources section, go to Descriptors, ADF META-INF and double click on adf-config.xml file. Select MDS Configuration tab, click on green plus icon in the top right corner and search for MyCC class. Confirm changes.


Create new JSPX file in the ViewController project. Add few output text components.



Save all and restart JDeveloper. During next run please select Customization Developer role.



Please check Application Navigator nodes. Some files has got lock icon on them, that means they aren't customizable.


There is additional panel called Customization Context. At the time you can see the file without any customizations or you can select layer and value that you want to change.


For this example first layer will hide "Layer 2" output text - click on the node and change rendered attribute to false in Property Inspector. Do similar work for second layer and "Layer 1" label.

The layer and its value will be evaluated during each request (please check getCacheHint method in the MyCC class). Value changes every each second so to verify result you must refresh page after a second.

Please run and check the example.

No comments:

Post a Comment