Showing posts with label MDS. Show all posts
Showing posts with label MDS. Show all posts

Wednesday, July 10, 2013

ADF disclosed property problems in showDetailItem after enabling MDS


After MDS is enabled in ADF, If you have logic to show or hide showDetailItem using  tab.setDisclosed(), it might not work.

To solve this issue.
import org.apache.myfaces.trinidad.change.AttributeComponentChange;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.change.ComponentChange;
import org.apache.myfaces.trinidad.context.RequestContext;


ChangeManager changeManager = RequestContext.getCurrentInstance().getChangeManager(); ComponentChange disclosed = new AttributeComponentChange("disclosed",Boolean.TRUE); ComponentChange undisclosed = new AttributeComponentChange("disclosed",Boolean.FALSE); changeManager.addComponentChange(FacesContext.getCurrentInstance(), tabA,disclosed); changeManager.addComponentChange(FacesContext.getCurrentInstance(), tabB,undisclosed); AdfFacesContext.getCurrentInstance().addPartialTarget(tabA); AdfFacesContext.getCurrentInstance().addPartialTarget(tabB);


Friday, August 24, 2012

How to use ADF MDS without enabling ADF security


MDS needs some way to uniquely identify each logged in user. Sometimes we might have applications that don't use ADF Security. We have to write a custom class that helps MDS to distinguish users. You start with a class that extends oracle.mds.cust.CustomizationClass. You need to modify the code in red to get a unique value that identifies the logged in user.

package a.b.c;
import java.util.Map;import javax.faces.context.FacesContext;import oracle.mds.core.MetadataObject;
import oracle.mds.core.RestrictedSession;
import oracle.mds.cust.CacheHint;
import oracle.mds.cust.CustomizationClass;

public class MyUserCC extends CustomizationClass {
    private static final String DEFAULT_LAYER_NAME = "user";
    private String mLayerName;

    public MyUserCC () {
        mLayerName = "user";
    }

    public CacheHint getCacheHint() {
        return CacheHint.USER;
    }

    public String getName() {
        return mLayerName;
    }

// Change code in this method to get the current logged in user   
public String[] getValue(RestrictedSession sess, MetadataObject mo) {
  String user = null;

// Change the code below to suits your application    FacesContext ctx = FacesContext.getCurrentInstance();
        if (ctx != null) {
          Map sessionState = ctx.getExternalContext().getSessionMap();
          user = (String)sessionState.get("LOGGEDINUSER");
        }
        return  user != null ? new String[]{user} : null;
    }

}
 
 
Application/Project Settings
1. Right click on the ViewController Project
    select ADF View
     Check "Enable User Customizations"
     Select Radio "Across Sessions using MDS"
2. Open adf-config.xml  in the Overview View
In the MDS Configuration Tab
    Click the Add(+) button in Customizations Configurations match Path = "/" and select the Class you just created “a.b.c.MyUserCC”
In the view Tab
    Tags
          Select the tags and the attributes on the tags you want MDS to be enabled on in the application.
 
JSPX/JSFF UI component  Settings
Go to the component you want MDS to work.  Change the attribute persist="ALL" for all properties to work
if you dont want some of them use  dontPersist="displayIndex frozen" (You can use all features you want seperated by a space in both persist and dontPersist attribute. )