1

I am using dandelion in order to show a table (from an hibernate DB):

<datatables:table id="listPersons" data="${listPersons}" row="person" 
                  cellspacing="0" width="100%"
                  theme="bootstrap2" pageable="true" info="true">
        <datatables:column title="Person" property="person"/>
        <datatables:column title="Car" property="car"/>
</datatables:table>

it works fine.

But, I need to add additional two columns from a Parents class (hibernate DB): "Father name" and Mother name". The class (which also hibernate) have the variable: Parents parents;

I tried something like:

<c:forEach items="${person.parents}" var="parents"> 
    <datatables:column title="Father name" property="parents.father_name"/>
</c:forEach>

But I got the exception:

javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.NoSuchMethodException: Unknown property 'father_name' on class 'class org.hibernate.collection.internal.PersistentBag'

I tried doing it in many variations (using dandelion datatables) but no one works.

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
Mike
  • 1,007
  • 2
  • 16
  • 33

1 Answers1

1

You should change to

<datatables:column title="Father name">
    <c:forEach items="${person.parents}" var="parent">
        <c:out value="${parent.father_name}"/>
    </c:forEach>
</datatables:column>

The problem you're having is that property="parents.father_name"/> is not using the variable you've set in forEach, rather uses the parents property from the hibernate entity which is a collection

Master Slave
  • 27,771
  • 4
  • 57
  • 55