Search code examples
javajspjpaeclipselinkpersistence

Using JPA and Eclipselink to display data from existing database table in a JSP file


Unsure if I am missing a step in this process somewhere or if its just syntax as I am new to this structure. I am only going to back to my bean for now but if needed I can put up my logical class, model class and anything else. This is what my JSP looks like:

        <h:dataTable 
            id="viewExampleTable" 
            value="#{ExampleBean.exampleList}"
            binding="#{ExampleBean.exampleTable}"
            var="example"
            styleClass="dataTable" border="1"
            style="width: 500px; word-wrap: break-word;"
            columnClasses="colWidth80,colWidth80,colWidth80,colWidth80">
            <h:column>
                <h:outputText value="example.Id"></h:outputText>
            </h:column>
            <h:column>
                <h:outputText value="example.importDate"></h:outputText>
            </h:column>
            <h:column>
                <h:outputText value="example.serviceId"></h:outputText>
            </h:column>
            <h:column>
                <h:outputText value="example.rowTimestamp"></h:outputText>
            </h:column>
        </h:dataTable>

This is the Bean:

private HtmlDataTable exampleTable;
private ArrayList exampleList = new ArrayList();

public HtmlDataTable getExampleTable(){
   return this.exampleTable;
}

public void setExampleTable(HtmlDataTable dataTable){
   this.exampleTable = dataTable;
}

public ArrayList<Example> getExample(){
   ArrayList<Example> list = ExampleLogic.getExampleRecords();
   this.exampleList = list;
   return this.exampleList
}

public void setExample(ArrayList<Example> list){
   this.exampleList = list;
}

This issue I'm having is that whenever this is deployed to the server I am getting this error:

javax.faces.el.PropertyNotFoundException: Error getting property 'exampleList' from bean of type examplePath.view.ExampleBean

And just a blank screen. Any help is appreciated as I've done my best researching and am at a loss on how to proceed.


Solution

  • This issue was resolved by renaming the getter in the Bean to what was being called in the value parameter in the jsp data table.

    Bean -> getExampleList() jsp -> value="#{bean.ExampleList}"

    This is only if I want to keep the ArrayList private as the error I was receiving was because the variable was private and the gettter didn't match what I was calling.