我的意图是从数据表中获取 back bean 的值,我将通过单击选择特定行,使用属性“rowSelectListener”我将点击 back bean 中可用的方法。问题是,我在单个项目中得到它,当我尝试与我的项目集成时,它显示方法调用错误。
这是我的xhtml
编码。
<ace:dataTable id="studAttendanceTable"
selectionMode="single"
value="#{adminStudentAttendenceMBean.allStudentAttendanceList}"
var="someVar" paginator="true" rows="12"
rowSelectListener="#{adminStudentAttendenceMBean.rowListener}">
<ace:column headerText="Month">
<h:outputText value="#{someVar.month}" />
</ace:column>
<ace:column headerText="Year">
<h:outputText value="#{someVar.year}"/>
</ace:column>
<ace:column headerText="Id">
<h:outputText value="#{someVar.studentInfoTable.studentId}" />
</ace:column>
<ace:column headerText="Student Name">
<h:outputText value="#{someVar.studentInfoTable.studentName}" />
</ace:column>
</ace:dataTable>
我的豆类:
public void rowListener(SelectEvent e) {
Integer[] selectedRow = (Integer[]) e.getObject();
List<StudentAttendanceTable> editList = new ArrayList<StudentAttendanceTable>(Arrays.asList((StudentAttendanceTable)e.getObject()));
for(StudentAttendanceTable ele :editList)
System.out.println(ele.getStudentAttendanceId());
}
这里的错误代码是:
Dec 13, 2013 4:01:32 PM com.sun.faces.lifecycle.InvokeApplicationPhase execute
WARNING: /admin/studentattendance.xhtml @50,76 rowSelectListener="#{adminStudentAttendenceMBean.rowListener}": java.lang.ClassCastException: com.eschool.model.StudentAttendanceTable cannot be cast to [Ljava.lang.Integer;
javax.el.ELException: /admin/studentattendance.xhtml @50,76 rowSelectListener="#{adminStudentAttendenceMBean.rowListener}": java.lang.ClassCastException: com.eschool.model.StudentAttendanceTable cannot be cast to [Ljava.lang.Integer;
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:111)
at org.icefaces.ace.component.datatable.DataTable.broadcast(DataTable.java:318)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:786)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1251)
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:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.eschool.util.SessionValidationFilter.doFilter(SessionValidationFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.eschool.model.StudentAttendanceTable cannot be cast to [Ljava.lang.Integer;
at com.eschool.bean.AdminStudentAttendenceMBean.rowListener(AdminStudentAttendenceMBean.java:539)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:274)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
... 26 more
如何纠正这个错误。