托管bean上找不到属性

时间:2013-05-10 21:51:08

标签: java primefaces

我遇到的问题是managedBean没有找到方法

这是我的managedBean

public float res ;

public List<Reglement> lister()
{

    List<Reglement>  L = regdao.getListR(reglement.getType_reg());

    System.out.println(reglement.getType_reg());
    System.out.println(this.getDate_debut());
    System.out.println(this.getDate_fin());

    return  L;
}

他是我的xhtml文件

<p:dataTable id="dt" var="p"  value="#{reglementMB.lister}"
        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
        rowsPerPageTemplate="2,5,9" paginator="true" rows="2"
        style="width:850px">


        <f:facet name="header">
            <h:outputText value="RESULTAT =  " />
        </f:facet>


        <p:column>
            <f:facet name="header">
                <h:outputText value="Montant " />
            </f:facet>
            <h:outputText value="#{p.reglement.montant_reg}" />
        </p:column>


        <p:column>
            <f:facet name="header">
                <h:outputText value="Date" />
            </f:facet>
            <h:outputText value="#{p.reglement.date_reg}" />
        </p:column>
    </p:dataTable>

这是我的错误,声称托管bean没有找到属性,尽管它存在于托管bean中

exception
javax.servlet.ServletException: /RSReglement.xhtml @56,24 value="#{reglementMB.lister}": Property 'lister' not found on type managedBean.ReglementMB
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)

    cause mère    
javax.el.PropertyNotFoundException: /RSReglement.xhtml @56,24 value="#{reglementMB.lister}": Property 'lister' not found on type managedBean.ReglementMB
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
javax.faces.component.UIData.getValue(UIData.java:731)
org.primefaces.component.datatable.DataTable.getValue(DataTable.java:729)
org.primefaces.component.api.UIData.getDataModel(UIData.java:581)
javax.faces.component.UIData.getRowCount(UIData.java:356)
org.primefaces.component.api.UIData.calculatePage(UIData.java:156)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:178)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:74)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
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:594)

1 个答案:

答案 0 :(得分:6)

您需要将方法lister重命名为getLister以遵循Java bean约定。

当您编写此代码#{reglementMB.lister}时,呈现该页面的代码将在您的bean中查找名为getLister()的方法。