JSFJavaBean属性链接问题
我正在尝试将我的jsf文件链接到java bean的属性。如果我在JavaBean中查找的属性不存在,则会出现错误。但是它存在于豆子里 班级。你能帮忙吗 函数流是index.xhtml,它将接受一个输入,在Bean中运行一个方法,并返回一个列表,显示在routesbystop.html中JSFJavaBean属性链接问题,jsf,Jsf,我正在尝试将我的jsf文件链接到java bean的属性。如果我在JavaBean中查找的属性不存在,则会出现错误。但是它存在于豆子里 班级。你能帮忙吗 函数流是index.xhtml,它将接受一个输入,在Bean中运行一个方法,并返回一个列表,显示在routesbystop.html中 **index.xhtml** <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o
**index.xhtml**
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/WEB-INF/templates/base_template.xhtml">
<ui:define name="content">
<h:form>
<h:body style="background:#F0F8FF">
<div
style="text-align: center; margin: 10px auto; padding: 5px 10px 5px 10px; border-bottom: dotted 1px #7c7c7c; overflow: hidden;">
<h1>Welcome to Toronto Bus Route</h1>
<h:commandButton action="routes" value="Retrieve Available Routes"/><br></br>
<h:inputText id="stopId" value="stopId"/><br></br>
<h:commandButton action="routebystop" value="Search" id="SearchRouteByStopId"/>
</div>
</h:body>
</h:form>
</ui:define>
</ui:composition>
</html>
**routebystop.xhtml**
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<f:metadata>
<f:event type="preRenderView" listener="#{routeByStopBean.retrieveSubRoutes}"></f:event>
</f:metadata>
<ui:composition template="/WEB-INF/templates/base_template.xhtml">
<ui:define name="content">
<h:form>
<h:body style="background:#F0F8FF">
<p:dataTable id="dataTable" var="routeByStopListData"
value="#{routeByStopBean.routeListDataClass}"
emptyMessage="No routes are found."
paginator="#{fn:length(routeByStopBean.routeListDataClass) > 10}"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20,50,100" rowVarIndex="rowIndex">
<f:facet name="header">
List of Stops
</f:facet>
<p:column headerText="Route Id">
<h:outputText value="#{routeByStopListData.routeNumber}" />
</p:column>
<p:column headerText="Route Name">
<h:outputText value="#{routeByStopListData.routeName}" />
</p:column>
</p:dataTable>
</h:body>
</h:form>
</ui:define>
</ui:composition>
</html>
faces-config
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
version="2.1">
<navigation-rule>
<display-name>WEB-INF/route.xhtml</display-name>
<from-view-id>/routes.xhtml</from-view-id>
<navigation-case>
<from-outcome>stops</from-outcome>
<to-view-id>stops.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>WEB-INF/index.xhtml</display-name>
<from-view-id>/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>routebystop</from-outcome>
<to-view-id>routebystop.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Bean class
package com.nextbus.ttc.bean;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import com.nextbus.ttc.dto.RouteListDataClass;
import com.nextbusroute.ttc.xmlparser.RouteListByStopDataHandler;
@ManagedBean
@SessionScoped
public class RouteByStopBean {
public List<RouteListDataClass> routeListDataClass;
public void retrieveSubRoutes(ComponentSystemEvent event) {
if (!FacesContext.getCurrentInstance().isPostback()) {
String stopNumber = (String) FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap()
.get("stopId");
RouteListByStopDataHandler s = new RouteListByStopDataHandler();
routeListDataClass = s.getRouteListByStop(stopNumber);
}
}
/**
* @return the RouteListDataClass
*/
public List<RouteListDataClass> getRouetListDataClass() {
return routeListDataClass;
}
public void setRouteListDatas(List<RouteListDataClass> routeListDataClass) {
this.routeListDataClass = routeListDataClass;
}
}
Error -
ception
javax.servlet.ServletException: Property 'routeListDataClass' not found on type com.nextbus.ttc.bean.RouteByStopBean
javax.faces.webapp.FacesServlet.service(FacesServlet.java:521)
root cause
javax.el.PropertyNotFoundException: Property 'routeListDataClass' not found on type com.nextbus.ttc.bean.RouteByStopBean
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
javax.el.BeanELResolver.property(BeanELResolver.java:325)
javax.el.BeanELResolver.getValue(BeanELResolver.java:85)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:183)
org.apache.el.parser.AstFunction.getValue(AstFunction.java:103)
org.apache.el.parser.AstGreaterThan.getValue(AstGreaterThan.java:38)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
org.primefaces.component.api.UIData.isPaginator(UIData.java:90)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:152)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:884)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1681)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:854)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1674)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:509)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.39 logs.
Apache Tomcat/7.0.39
**index.xhtml**
欢迎来到多伦多巴士路线
**routebystop.xhtml**
站点列表
面配置
WEB-INF/route.xhtml
/routes.xhtml
停止
stops.xhtml
WEB-INF/index.xhtml
/index.xhtml
路由系统
routebystop.xhtml
豆类
包com.nextbus.ttc.bean;
导入java.util.List;
导入javax.faces.bean.ManagedBean;
导入javax.faces.bean.SessionScoped;
导入javax.faces.context.FacesContext;
导入javax.faces.event.ComponentSystemEvent;
导入com.nextbus.ttc.dto.RouteListDataClass;
导入com.nextbusroute.ttc.xmlparser.RouteListByStopDataHandler;
@ManagedBean
@会议范围
公共类RouteByStopBean{
公共列表routeListDataClass;
公共无效检索子路由(ComponentSystemEvent事件){
如果(!FacesContext.getCurrentInstance().isPostback()){
字符串stopNumber=(字符串)FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap()
.get(“stopId”);
RouteListByStopDataHandler s=新的RouteListByStopDataHandler();
routeListDataClass=s.getRouteListByStop(stopNumber);
}
}
/**
*@返回RouteListDataClass
*/
公共列表getRouetListDataClass(){
返回routeListDataClass;
}
公共无效setRouteListDatas(列出routeListDataClass){
this.routeListDataClass=routeListDataClass;
}
}
错误-
概念
javax.servlet.ServletException:在com.nextbus.ttc.bean.RouteByStopBean类型上找不到属性“routeListDataClass”
javax.faces.webapp.FacesServlet.service(FacesServlet.java:521)
根本原因
javax.el.PropertyNotFoundException:在com.nextbus.ttc.bean.RouteByStopBean类型上找不到属性“routeListDataClass”
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:237)
javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:214)
属性(BeanELResolver.java:325)
getValue(BeanELResolver.java:85)
com.sun.faces.el.DemuxCompositeELResolver.\u getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:183)
org.apache.el.parser.AstFunction.getValue(AstFunction.java:103)
org.apache.el.parser.astgreeaterthan.getValue(astgreeaterthan.java:38)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
org.primefaces.component.api.UIData.isPaginator(UIData.java:90)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:152)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:884)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1681)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:854)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1674)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:509)
注意,Apache Tomcat/7.0.39日志中提供了根本原因的完整堆栈跟踪。
ApacheTomcat/7.0.39
您在bean中将getRouteListDataClass
拼写为getRouetListDataClass
。这个问题似乎离题了,因为它只是一个打字错误。