我有一个使用primefaces的DataTable复合组件。
<cc:interface>
<cc:attribute name="amountToAllocate" />
<cc:attribute name="transactionsToAllocate" />
<cc:attribute name="selectedTransactions" />
<cc:attribute name="allocateAutoUpdateId" />
<cc:attribute name="amountAllocated" />
<cc:attribute name="allocationRemaining" />
<cc:attribute name="rowSelectUpdateId" />
<cc:attribute name="allocateAutoListener"
method-signature="void action()" />
<cc:attribute name="toggleSelectListener"
method-signature="void action(org.primefaces.event.ToggleSelectEvent)" />
<cc:attribute name="selectRowListener"
method-signature="void action(org.primefaces.event.SelectEvent)" />
<cc:attribute name="unselectRowListener"
method-signature="void action(org.primefaces.event.UnselectEvent)" />
</cc:interface>
<cc:implementation>
<p:dataTable value="#{cc.attrs.transactionsToAllocate}"
var="transaction"
selection="#{cc.attrs.selectedTransactions}"
rowKey="#{transaction.transactionId}" >
<p:ajax event="toggleSelect"
listener="#{cc.attrs.toggleSelectListener}"
update="#{cc.attrs.rowSelectUpdateId}" />
<p:ajax event="rowSelectCheckbox"
listener="#{cc.attrs.selectRowListener}"
update="#{cc.attrs.rowSelectUpdateId}" />
<p:ajax event="rowUnselectCheckbox"
listener="#{cc.attrs.unselectRowListener}"
update="#{cc.attrs.rowSelectUpdateId}" />
<p:column selectionMode="multiple"
style="width:16px;text-align:center"/>
<p:column headerText="Reference">
#{transaction.reference}
</p:column>
<p:column headerText="Invoice Date">
<h:outputText value="#{transaction.transactionDate}">
<f:convertDateTime pattern="dd/MM/yy" />
</h:outputText>
</p:column>
</p:dataTable>
</cc:implementation>
它的实现在这里:------------------------
<h:panelGroup id="alloc">
<ezcomp:transactionAllocation amountToAllocate="#{apCreditNoteTransactionBean.transaction.value}"
transactionsToAllocate="#{apCreditNoteTransactionBean.transactionAllocationInvoiceData.unallocatedTransactions}"
selectedTransactions="#{apCreditNoteTransactionBean.transactionAllocationInvoiceData.selectedUnallocatedTransactions}"
allocateAutoListener="#{apCreditNoteTransactionBean.autoAllocateTransactionToSelectedTransaction}"
allocateAutoUpdateId=":#{p:component('alloc')}"
amountAllocated="#{apCreditNoteTransactionBean.transactionAllocationInvoiceData.amountAllocated}"
allocationRemaining="#{apCreditNoteTransactionBean.transaction.value-apCreditNoteTransactionBean.transactionAllocationInvoiceData.amountAllocated}"
toggleSelectListener="#{apCreditNoteTransactionBean.onToggleSelect}"
selectRowListener="#{apCreditNoteTransactionBean.onRowSelect}" unselectRowListener="#{apCreditNoteTransactionBean.onRowUnSelect}"
rowSelectUpdateId=":#{p:component('alloc')}"
/>
</h:panelGroup>
问题是当取消选择它引发错误的行时:
引起:javax.el.PropertyNotFoundException:Property&#39; onRowUnSelect&#39;在类型beans.APCreditNoteTransactionBean
上找不到我在bean中定义了方法:
public void onRowUnSelect(UnselectEvent event) {
}
但如果rowUnselectCheckbox监听器直接从托管bean分配为
,则可以正常工作<p:ajax event="rowUnselectCheckbox" listener="#{apCreditNoteTransactionBean.onRowUnSelect}" update="#{cc.attrs.rowSelectUpdateId}" />
但是其他事件:toggleSelect和rowSelectCheckBox导致以下错误:
java.lang.ArrayIndexOutOfBoundsException: 0
at org.apache.el.parser.AstValue.convertArgs(AstValue.java:303)
at org.apache.el.parser.AstValue.invoke(AstValue.java:257)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:277)
at com.sun.faces.facelets.el.ContextualCompositeMethodExpression.invoke(ContextualCompositeMethodExpression.java:189)
at com.sun.faces.facelets.tag.TagAttributeImpl$AttributeLookupMethodExpression.invoke(TagAttributeImpl.java:477)
at org.primefaces.behavior.ajax.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxBehaviorListenerImpl.java:53)
at org.primefaces.event.ToggleSelectEvent.processListener(ToggleSelectEvent.java:40)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:804)
at javax.faces.component.UIData.broadcast(UIData.java:1086)
at javax.faces.component.UIData.broadcast(UIData.java:1108)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
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:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1575)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1533)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)