How to open - call Task flow from tree menu

This example assumes that you work have UIShell template as a template for your page
 1- After creating the tree that contains a tree hierarchy  of the system menus , in  jsf page click on the tree component then open the property inspector for the tree
2- on the selection listener property of the tree , cut the selection listener value , for example #{bindings.UserAppMenu.treeModel.makeCurrent}" and create new selection listener on the managed bean , name it for example #{menuBean.onTreeMenuSelection}
3- make sure that the selectedRowKey property of the tree is null

4- the jsf code should be like this

   <af:tree value="#{bindings.MenuTreeVo.treeModel}" var="node"
                                             selectionListener="#{menuBean.onTreeMenuSelection}" rowSelection="single" binding = "#{menuBean.menuTree}"
                                             id="t1">
                                        <f:facet name="nodeStamp">
                                                    <af:link text="#{node.MenuName}" id="ot1" icon="/images/menu.gif"/>                                            
                                        </f:facet>
    </af:tree>



in your managed bean implement the selection listener

 private String taskFlowName;
 private String tabTitle;
private String action;
 private RichTree menuTree;
 public void setMenuTree(RichTree menuTree) {
        this.menuTree = menuTree;
    }
    public RichTree getMenuTree() {
        return menuTree;
    }

 /**
     * @param selectionEvent
     * this methos fire on clec in the ress menu navigator
     * to open the target page fragment
     * tarek
     * tree menu navigation
     * open the taskflow
     */
    public void onTreeMenuSelection(SelectionEvent selectionEvent) {
        resloveMethodExpression("#{bindings.UserAppMenu.treeModel.makeCurrent}", null, new Class[] {
                                SelectionEvent.class }, new Object[] { selectionEvent });
        RowKeySet rks = getMenuTree().getSelectedRowKeys();
        Iterator keys = rks.iterator();
        while (keys.hasNext()) {
            List key = (List) keys.next();
            getMenuTree().setRowKey(key);
            JUCtrlHierNodeBinding node = (JUCtrlHierNodeBinding) getMenuTree().getRowData();
            Row rw = node.getRow();
            setAction((String) rw.getAttribute("Action"));
            setTaskFlowName((String) rw.getAttribute("ActionString"));
            setTabTitle((String) rw.getAttribute("MenuTitle"));
            TabContext tabContext = TabContext.getCurrentInstance();
            if (getTaskFlowName() != null) {
                try {
                    if (tabContext.getSelectedTabIndex() != -1) {
                        tabContext.removeCurrentTab();
                    }
                    tabContext.addTab(getTabTitle(), getTaskFlowName());
                } catch (TabContext.TabOverflowException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    /**
     * @param expression
     * @param returnType
     * @param argTypes
     * @param argValues
     * @return
     * Helper method
     */
    public static Object resloveMethodExpression(String expression, Class returnType, Class[] argTypes,
                                                 Object[] argValues) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application app = facesContext.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = facesContext.getELContext();
        MethodExpression methodExpression =
            elFactory.createMethodExpression(elContext, expression, returnType, argTypes);
        return methodExpression.invoke(elContext, argValues);
    }

note
make sure that the UIShell is bindind to "oracle.ui.pattern.dynamicShell.model.dynamicTabShellDefinition"


Comments

Popular posts from this blog

Another user has changed the row with primary key oracle.jbo.Key[12 ].

weblogic windows JPS-01050: Opening of wallet based credential store failed. Reason java.io.IOException: Failed to lock cwallet.sso.lck

Working With File Throgh WebUtill