Sam K
Sam K

Reputation: 41

DisplayTag error

I am using the DisplayTag with pagination to display a List objects. The Transactions has a property called 'company' / getCompany() which is the Company object. The Company object contains a String called 'name' / getName().

My code looks like this:

<display:table name="${transactions}" id="transaction" pagesize="2" defaultsort="1">  

<display:column property="id" title="ID" href="showTransactionDetails.html" paramId="id" />
<display:column property="company.name" title="Company Name" sortable="true"    >
<display:column property="status" title="Status" sortable="true">

</display:table>

Here is the strange part.... Everything works great when the first page is displayed and there are a total of 11 pages with each page containing 2 records.

I can click on a page number and see the page advance. But for some strange reason, when I click on page (2-4) I get an exception:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception: [.LookupUtil] Error looking up property "company.name" in object type "com.replacements.entity.Transaction". Cause: null

(It's also important to note that all of the Transaction records contain a value for the company.name since its a required field in my DB)

Upvotes: 2

Views: 4859

Answers (8)

Gpak
Gpak

Reputation: 3390

Make sure you have setters and getters methods for all attributes in your class and names matching attributes names.

Upvotes: 0

Williams Ilenikhena
Williams Ilenikhena

Reputation: 1

A requestURI tag...like so.... requestURI="

Upvotes: 0

Sam K
Sam K

Reputation: 41

I solved it by changing the company property in Hibernate mapping to "lazy=false"

I'm still not sure why the pagination worked from some pages and not all. But this fixed it.

Thank you all for your ideas.

Upvotes: 2

Marcus Leon
Marcus Leon

Reputation: 56659

Try changing the name="${transactions}" in the display:table tag to name="transactions".

Assuming you have the transactions collection in the session or request or whatever.

Upvotes: 1

BalusC
BalusC

Reputation: 1108537

The exception message literally tells that the Transaction is null. Thus, there's apparently a null item in the transaction list behind ${transactions}. Look like a fault in the loading/populating logic of the transaction list. Maybe the last item is null? Or maybe the list is request scoped and dependent from some request parameters which are missing in the subsequent request so that loading/populating the list failed?

For the interested, if Company was null as some suggests, EL would not have error'ed that way. It would have mentioned object type Company instead.

Upvotes: 0

Ben
Ben

Reputation: 2801

My first guess is that there is an empty company list. I would suggest you print dump to output your transaction results before they get to the display part.

If that’s not the problem I’ve seen display problems caused by special characters. One of the company names might contain a control character or some other non-displayable character.

Upvotes: 1

Marcus Leon
Marcus Leon

Reputation: 56659

As @Vincent says, likely company is null. You may have a value in your database, but maybe there is an issue where your Transaction class isn't properly reading the db value and setting its company member. Have you tried setting a breakpoint and looking at the Transaction instance?

Upvotes: 1

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

Is it possible that the company is null. That is, you have a transaction with no company in the database.

Upvotes: 2

Related Questions