12 Replies Latest reply on Jul 5, 2012 5:06 AM by adfLearner

    phase listener phase invoking doubts?

    Subramanian Meyyappan
      hi experts,

      i wrote a method named x in Application module it return will some string. i expose that method on client interface.

      i invoked the method x using methodaction in my jsff.

      ok fine.

      i had jsff presented inside bounded TF

      in my jsff i had some panel tabbed. while clicking the jsff the method which i wrote was to be executed.
      public class x implements PhaseListener {
             public void beforePhase(PhaseEvent phaseEvent) {
              System.out.println("Before Phase");
              if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE)
              BindingContainer bindings = getBindings();
              OperationBinding oper = bindings.getOperationBinding("Scheme");
              Object result = oper.execute();
              System.out.println("result" + result);
      but it always return null pointer.
      if wrote in after phase no more exception but never executed

      error is self explanatory. but i unabled ? how can i fix this?
      Before Phase
      <UIViewRoot> <notifyPhaseListeners> Exception
      javax.el.ELException: java.lang.NullPointerException
           at com.sun.el.parser.AstValue.invoke(Unknown Source)
           at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
           at javax.faces.component.UIViewRoot.notifyPhaseListeners(UIViewRoot.java:608)
           at javax.faces.component.UIViewRoot.notifyBefore(UIViewRoot.java:510)
           at javax.faces.component.UIViewRoot.encodeBegin(UIViewRoot.java:564)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:928)
           at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
           at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
           at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:189)
           at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:193)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:800)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:294)
           at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:214)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
           at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
           at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
           at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
           at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
           at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
           at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
           at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
           at java.security.AccessController.doPrivileged(Native Method)
           at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
           at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
           at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
           at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
           at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
           at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
           at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
           at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
           at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
           at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
           at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
           at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
      Caused by: java.lang.NullPointerException
           at com.rits.suplr.view.Listeners.PrintPage.beforePhase(PrintPage.java:79)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           ... 52 more
      <UIViewRoot> <notifyPhaseListeners> Exception while processing expression #{PrintPage.beforePhase} for attribute beforePhase.
        • 1. Re: phase listener phase invoking doubts?
          John Stegeman

          Show us line 79...
          Tell us exactly what you are trying to do here (aka - tell us the use case) - it seems a bit fishy to be doing this in a Phase Listener, but without knowing the use case, hard to say...

          • 2. Re: phase listener phase invoking doubts?
            Subramanian Meyyappan
            Object result = oper.execute();
            this is the line.

            simple what i need?
            i wrote method in am it will return some data.

            say as eg:
            ApplicationModule Method
            public String method ()
            return some of the vo data.
            based on the Am method return data:
            if method returns value 'p' means some field which is present inside jsff should be -get disabled this should be happens at the jsff page rendering.
            if method returns some other value means some of the fields get enabled.

            i hope you understood.

            if not please tell me. here am to represent more in details.

            forget metion details
            jdev adfbc
            • 3. Re: phase listener phase invoking doubts?
              John Stegeman
              The error is that the binding context (aka your page definition) doesn't have a binding for the method you exposed you'd need to add it

              HOWEVER - Don't do this in a phase listener.

              Just bind the disabled property of the fields to some EL that utilises the method exposed.
              • 4. Re: phase listener phase invoking doubts?
                Subramanian Meyyappan
                <methodAction id="Scheme" InstanceName="SupplierAMDataControl.dataProvider"
                                  DataControl="SupplierAMDataControl" RequiresUpdateModel="true"
                                  Action="invokeMethod" MethodName="Scheme"
                yes i know. i already did that
                i already says that error is self explanatory though i cant fix it.
                HOWEVER - Don't do this in a phase listener.
                why are you saying like this?

                Just bind the disabled property of the fields to some EL that utilises the method exposed.
                please correct me if am wrong is this right
                #{bindings.Scheme.result eq 'P' ? true : false}

                here where Scheme is AM method.

                thanks john :) for answering me.
                • 5. Re: phase listener phase invoking doubts?
                  John Stegeman
                  why are you saying like this
                  1). Because you don't need to. People tend to over-use phase listeners when learning ADF, but in 90% of the cases I've seen, there's a simpler solution
                  2). Because in phase listeners, you may or may not have access to things you need (such as binding containers :) )
                  please correct me if am wrong is this right
                  Yes, it looks OK - test it out
                  • 6. Re: phase listener phase invoking doubts?
                    Subramanian Meyyappan
                    ok coming to your line.,

                    this am method.
                     public String Scheme()
                            HrmBustripCntrlVOImpl vo1 = (HrmBustripCntrlVOImpl)this.getHrmBustripCntrl1();
                            Row row1 = vo1.first();
                            System.out.println("Scheme:" + row1.getAttribute("HbtrcScheme"));
                            return (String)row1.getAttribute("HbtrcScheme");
                    in my jsff one the panel tabbed
                    <af:selectBooleanCheckbox value="#{bindings.BtrAdvReqFlag.inputValue}"
                                                                  label="Advance Req."
                                                                  disabled="#{bindings.Scheme.execute eq 'P' ? true : false}"/> //here
                    checkbox is not disabling. i dont know is this right way to disabling some of the component based on some condition while jsff renders?

                    -- edited lately

                    is there additional things have to be added.
                    • 7. Re: phase listener phase invoking doubts?
                      Subramanian Meyyappan
                      is there any other way to achieve my need. i tried as you said. method in am present in pagedef.
                      check box not even disabling.

                      can anyone .

                      Edited by: ADF7 on Jul 4, 2012 4:54 AM
                      • 9. Re: phase listener phase invoking doubts?
                        Follow the below steps :

                        1. Create MethodActionBinding in your pageDef for the AM method.
                        2. disabled = "<someMethodOfbean returning true false>"
                        3. Execute the methodactionBinding in that bean method.

                        This works ... I have tested it in a sample app.

                        • 10. Re: phase listener phase invoking doubts?
                          Subramanian Meyyappan
                          could you please post the sample file in some file hoster.

                          2. disabled = "<someMethodOfbean returning true false>" // how are you saying
                          3. Execute the methodactionBinding in that bean method. // here i get you .
                          bit elobaratore more.

                          Edited by: ADF7 on Jul 4, 2012 6:06 AM
                          • 11. Re: phase listener phase invoking doubts?
                            well I created the poc in my office desktop. Will post the code tomorrow for your reference.

                            • 12. Re: phase listener phase invoking doubts?

                              download the sample application from the below URL.


                              Let me know if you have any questions.

                              1 person found this helpful