This discussion is archived
4 Replies Latest reply: Mar 3, 2013 11:08 PM by wmaarbani RSS

How To Combine bindings.graphModel.processClick with custom action

wmaarbani Newbie
Currently Being Moderated
Dear All,
I have created two charts with master detail relationship so by default i have in the ClickListener field #{bindings.EMP_COUNT_LOC_VO11.graphModel.processClick}.
I have created a Managed Bean with will show the data value i clicked on.
The problem is how to combine these two action in the ClickListener.
Please advice.
Thanks in advance.
  • 1. Re: How To Combine bindings.graphModel.processClick with custom action
    Bijesh Krishnadas Journeyer
    Currently Being Moderated
    As with any other ADF listener, edit the click listener property and attach to a managed bean method. The wizard will create the method with the right signature for you.

    In the managed bean method, after processing your business logic, invoke the processClick method via the MethodExpression. Sample code below
    public void clickListener(ClickEvent clickEvent) {
            //Business Logic goes here..
    
            FacesContext facesContext = getFacesContext();
            Application app = facesContext.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = facesContext.getELContext();
            MethodExpression methodExpression = 
                elFactory.createMethodExpression(elContext, "#{bindings.EMP_COUNT_LOC_VO11.graphModel.processClick}", new Class[]{}, new Class[]{ClickEvent.class});
            methodExpression.invoke(elContext, clickEvent);
    }
    This technique can be used with any EL method invocation.
  • 2. Re: How To Combine bindings.graphModel.processClick with custom action
    wmaarbani Newbie
    Currently Being Moderated
    when i insert the cod it give me the following errors.
    Could you help me please i am still a beginner in ADF.
    Thanks in advance

    FacesContext facesContext;
    facesContext = getFacesContext();
    // Error(71,24): cannot find method getFacesContext()
    Application app;
    app = facesContext.getApplication();
    //Error(73,42): incompatible types
    ExpressionFactory elFactory = app.getExpressionFactory();
    //Error(74,42): cannot find method getExpressionFactory()
    ELContext elContext = facesContext.getELContext();
    MethodExpression methodExpression = elFactory.createMethodExpression(elContext, "#{bindings.EMP_COUNT_LOC_VO11.graphModel.processClick}", new Class[]{}, new Class[]{ClickEvent.class});
    //Error(77,30): createMethodExpression(javax.el.ELContext,java.lang.String,java.lang.Class<?>,java.lang.Class<?>[]) in javax.el.ExpressionFactory cannot be applied to (javax.el.ELContext,java.lang.String,java.lang.Class[],java.lang.Class[])
    methodExpression.invoke(elContext, clickEvent);
    //Error(78,33): invoke(javax.el.ELContext,java.lang.Object[]) in javax.el.MethodExpression cannot be applied to (javax.el.ELContext,oracle.adf.view.faces.bi.event.ClickEvent)
  • 3. Re: How To Combine bindings.graphModel.processClick with custom action
    Bijesh Krishnadas Journeyer
    Currently Being Moderated
    public void clickListener(ClickEvent clickEvent) {
            //Business Logic goes here..
     
            FacesContext facesContext = FacesContext.getCurrentInstance(); /** edit */
            Application app = facesContext.getApplication(); /**  please check Javadoc for FacesContext to work out import*/
            ExpressionFactory elFactory = app.getExpressionFactory();  /**  please check Javadoc for FacesContext to work out import*/
            ELContext elContext = facesContext.getELContext();
            MethodExpression methodExpression = 
                elFactory.createMethodExpression(elContext, "#{bindings.EMP_COUNT_LOC_VO11.graphModel.processClick}", null, new Class[]{ClickEvent.class}); /** edit */
            methodExpression.invoke(elContext, new Object[]{clickEvent}); /**edit */
    }
    Some edits to the code. Please may I suggest that you read up on the javadoc for ADF and JSF. A lot of the code errors above could've been resolved if the javadocs are referred to.
  • 4. Re: How To Combine bindings.graphModel.processClick with custom action
    wmaarbani Newbie
    Currently Being Moderated
    Thanks Bijesh Krishnadas for your help and it works fine.
    I use the following code.

    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory elFactory = facesContext.getApplication().getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    MethodExpression methodExpression =
    elFactory.createMethodExpression(elContext, "#{bindings.EMP_COUNT_LOC_VO1.graphModel.processClick}", null, new Class[]{ClickEvent.class}); /** edit */
    methodExpression.invoke(elContext, new Object[]{clickEvent});

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points