开发者

How to call method expression with parameters?

Can i pass an expression as a method expression parameter like this ?

<p:dataTable id="gridRPBDetails" var="rpbDetail"
  value="#{tInputBean.detailList}"
  selection="#{tInputBean.selectedDetails}">

....

   <p:commandButton 
      process="@this" 
      action="#{tInputBean.querySubAnggaranListImpl(rpbDetail.map['budget'])}" ... />

....

</p:datatable>

I tried this but ended with exception :

DEBUG PhaseTracker - BEFORE PHASE INVOKE_APPLICATION 5
Apr 28, 2011 3:22:17 PM com.sun.faces.application.ActionListenerImpl processAction
SEVERE: java.lang.NullPointerException
javax.faces.el.MethodNotFoundException: java.lang.NullPointerException
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:104)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        at javax.faces.component.UICommand.broadcast(UICommand.java:315)
        at javax.faces.component.UIData.broadcast(UIData.java:915)
        at org.primefaces.component.datatable.DataTable.broadcast(DataTable.java:630)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:299)
        at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:172)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:251)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        ... 25 more
Apr 28, 2011 3:22:17 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: #{tInputBean.querySubAnggaranListImpl(rpbDetail.map['budget'])}: java.lang.NullPointerException
javax.faces.FacesException: #{tInputBean.querySubAnggaranListImpl(rpbDetail.map['budget'])}: java.lang.NullPointerException
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
        at javax.faces.component.UICommand.broadcast(UICommand.java:315)
        at javax.faces.component.UIData.broadcast(UIData.java:915)
        at org.primefaces.component.datatable.DataTable.broadcast(DataTable.java:630)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReport开发者_StackOverflow中文版Valve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.el.MethodNotFoundException: java.lang.NullPointerException
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:104)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        ... 24 more
Caused by: java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:299)
        at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:172)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:251)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        ... 25 more
DEBUG PhaseTracker - AFTER PHASE INVOKE_APPLICATION 5
javax.faces.FacesException: #{tInputBean.querySubAnggaranListImpl(rpbDetail.map['budget'])}: java.lang.NullPointerException
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:89)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: javax.faces.FacesException: #{tInputBean.querySubAnggaranListImpl(rpbDetail.map['budget'])}: java.lang.NullPointerException
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
        at javax.faces.component.UICommand.broadcast(UICommand.java:315)
        at javax.faces.component.UIData.broadcast(UIData.java:915)
        at org.primefaces.component.datatable.DataTable.broadcast(DataTable.java:630)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        ... 18 more
Caused by: javax.faces.el.MethodNotFoundException: java.lang.NullPointerException
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:104)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        ... 24 more
Caused by: java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:299)
        at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:172)
        at org.apache.el.parser.AstValue.invoke(AstValue.java:251)
        at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
        ... 25 more

Here's my action method (please note that rpbDetail.map['budget'] is a type of DataTransferObject, so it should fit right in) :

public void querySubAnggaranListImpl(DataTransferObject budget) {
    DebugUtil.start("querySubAnggaranListImpl");
    String budgetId = budget.getString("id");

    // cari subbudgetlist berdasarkan budgetId
    this.comboChainSubAnggaranList = ch.execute("common", "GetSubBudgetList", 
        new DataTransferObject()
            .putString("budgetId", budgetId))
        .getList("result");
    DebugUtil.end("querySubAnggaranListImpl");
}

I tried this out of deperation : action="#{tInputBean.querySubAnggaranListImpl(#{rpbDetail.map['budget']})}", and ended up with this error message on my browser :

/TInput.xhtml @161,40 action="#{tInputBean.querySubAnggaranListImpl(#{rpbDetail.map['budget']})}" The identifier [#] is not a valid Java identifier as required by section 1.19 of the EL specification (Identifier ::= Java language identifier). This check can be disabled by setting the system property org.apache.el.parser.SKIP_IDENTIFIER_CHECK to true.


How can i pass the parameter to the method expression like my case above ?

Thank you !


I finally found out that this was my mistake. It should be

rpbDetail.map.subBudget.map.budget. 

rpbDetail.map.budget returns null, hence the NullPointerException.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜