XML Menu tree in session scope
Hi I do have a tree code as below ;
<af:tree id="ccId"
value="#{PlsUserSession.ccMenu}" var="n"
initiallyExpanded="true" immediate="true"
fetchSize="25">
<f:facet name="nodeStamp">
<af:commandLink text="#{n.label}" id="pt_cl2"
action="#{n.doAction}"
partialSubmit="true"
immediate="true"/>
</f:facet>
</af:tree>
Where cc_menu is the xml menu bean created from an unbounded task flow. This code fails at {n.doAction} because of null pointer exception. Can anybody tell whats the issue here ? I tried to set the cc_menu in the session scope and accessed the tree but hitting the same issue.
<af:tree id="ccId"
value="#{cc_menu}" var="n"
initiallyExpanded="true" immediate="true"
fetchSize="25">
My idea is to put the xml menu into the user session.PlsUserSession is the managed bean defined in the session scope.
public class PlsUserSession {
private String currentUser;
private HashMap menuTree;
private oracle.adf.view.rich.model.MDSMenuModel ccMenu;
public PlsUserSession() {
if (this.currentUser == null) {
System.out.println("Creating User Session");
}
}
private HashMap getMenuTree() {
if (this.menuTree == null) {
System.out.println("Loading tree map");
this.menuTree = new HashMap();
this.menuTree.put("cc_menu", resolveExpression("#{cc_menu}"));
}
return this.menuTree;
}
public void setCurrentUser(String currentUser) {
System.out.println("setCurrentUser");
this.currentUser = currentUser;
}
public static Object resolveExpression(String expression) {
try {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, oracle.adf.view.rich.model.MDSMenuModel.class);
return (Object)valueExp.getValue(elContext);
} catch (Exception e) {
// Do something here...
;
}
return null;
}
public void setCcMenu(oracle.adf.view.rich.model.MDSMenuModel ccMenu) {
this.ccMenu = ccMenu;
}
public oracle.adf.view.rich.model.MDSMenuModel getCcMenu() {
if (this.menuTree == null) {
this.getMenuTree();
}
return (oracle.adf.view.rich.model.MDSMenuModel)this.menuTree.get("cc_menu");
}
}
Thanks
Suneesh