我在 tomcat7 中部署我的项目,并且在启动我的 jsf 时,我遇到了投射问题。当我删除 binding="#{courseBean.courseTable}" 我得到了我的表,但它是空的。我一步一步按照教程进行操作,但我不知道问题出在哪里。
org.apache.jasper.JasperException: An exception occurred processing JSP page /courselist.jsp at line 20
17: <h:form id="mainForm">
18:
19: <h:panelGrid columns="1">
20: <rich:scrollableDataTable id="courseTable"
21: binding="#{courseBean.courseTable}" value="#{courseBean.courseList}"
22: var="course" width="300px" height="200px">
23: <%-- <a4j:support event="onRowDblClick" <%-- action="#{courseBean.viewDetail}" --%> /> --%>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
org.ajax4jsf.Filter.doFilter(Filter.java:175)
cause mère
javax.faces.FacesException: java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1694)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:429)
javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:486)
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:670)
javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1142)
org.apache.jsp.courselist_jsp._jspx_meth_rich_005fscrollableDataTable_005f0(courselist_jsp.java:271)
org.apache.jsp.courselist_jsp._jspx_meth_h_005fpanelGrid_005f0(courselist_jsp.java:225)
org.apache.jsp.courselist_jsp._jspx_meth_h_005fform_005f0(courselist_jsp.java:181)
org.apache.jsp.courselist_jsp._jspx_meth_f_005fview_005f0(courselist_jsp.java:136)
org.apache.jsp.courselist_jsp._jspService(courselist_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
org.ajax4jsf.Filter.doFilter(Filter.java:175)
cause mère
java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.component.UIComponent
com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1683)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:429)
javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:222)
javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:486)
javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:670)
javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1142)
org.apache.jsp.courselist_jsp._jspx_meth_rich_005fscrollableDataTable_005f0(courselist_jsp.java:271)
org.apache.jsp.courselist_jsp._jspx_meth_h_005fpanelGrid_005f0(courselist_jsp.java:225)
org.apache.jsp.courselist_jsp._jspx_meth_h_005fform_005f0(courselist_jsp.java:181)
org.apache.jsp.courselist_jsp._jspx_meth_f_005fview_005f0(courselist_jsp.java:136)
org.apache.jsp.courselist_jsp._jspService(courselist_jsp.java:98)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:537)
com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:275)
com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:118)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:152)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:97)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:102)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
org.ajax4jsf.Filter.doFilter(Filter.java:175)
courselist.jsf:
<rich:scrollableDataTable id="courseTable"
binding="#{courseBean.courseTable}" value="#{courseBean.courseList}"
var="course" width="300px" height="200px">
<%-- <a4j:support event="onRowDblClick" <%-- action="#{courseBean.viewDetail}" --%> /> --%>
<rich:column id="code" width="60px">
<f:facet name="header">
<h:outputText value="Code" />
</f:facet>
<h:outputText value="#{course.code}" />
</rich:column>
<rich:column id="name" width="200px">
<f:facet name="header">
<h:outputText value="Nom" />
</f:facet>
<h:outputText value="#{course.name}" />
</rich:column>
<rich:column id="length" width="60px">
<f:facet name="header">
<h:outputText value="Longueur" />
</f:facet>
<h:outputText value="#{course.length}" />
</rich:column>
</rich:scrollableDataTable>
coursebean.java
public class CourseBean implements Serializable {
@Autowired
private transient courseService courseService;
private transient HtmlScrollableDataTable courseTable;
private List<Course> courseList;
private Course currentCourse;
@PostConstruct
public void init() {
courseList = courseService.findAll();
}
public String update() {
courseService.save(currentCourse);
init();
return null;
}
public HtmlScrollableDataTable getCourseTable() {
return courseTable;
}
public void setCourseTable(HtmlScrollableDataTable courseTable) {
this.courseTable = courseTable;
}
public List<Course> getCourseList() {
return courseList;
}
public void setCourseList(List<Course> courseList) {
this.courseList = courseList;
}
public Course getCurrentCourse() {
return currentCourse;
}
public void setCurrentCourse(Course currentCourse) {
this.currentCourse = currentCourse;
}
}