Java – property not found on managed bean

javaprimefaces

i have a problem that the managedBean didn't find the method

here is my 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;
}

and he re is my xhtml file

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

and here is my error which claim that the managed bean didn't found the property although it exists in the the managed 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)

Best Solution

You need to rename the method lister to getLister to follow the Java bean convention.

When you write this code #{reglementMB.lister}, the code rendering the page will look for a method called getLister() in your bean.

Related Question