0

我正在尝试将我的 jsf 文件链接到我的属性到 java bean。它给出错误说我在java bean中寻找的属性不存在。但它存在于 bean 类中。你能帮忙吗?

功能流程是 index.xhtml 将接受输入并在 Bean 中运行方法并返回要在 routesbystop.html 中显示的列表

**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
4

1 回答 1

0

你的拼写getRouteListDataClassgetRouetListDataClass你的 bean 一样。

于 2013-05-10T23:48:55.727 回答