« Return to Thread: Displaying related data from JPA query in JSF table component

RE: Displaying related data from JPA query in JSF table component

by Futaleufu_John :: Rate this Message:

Reply to Author | View in Thread

I hadn't thought of using views, but I may try that if I can't find another solution.

What bothers me is that the query results are an array of Contact POJOs. Each Contact POJO has a reference to an organization POJO, an address POJO, and a person POJO.

The table component's source data is:

    sourceData="#{SessionBean1.contacts} <=== array of Contact POJOs

If I select one of those objects, I can bind text fields as follows:

   text="#{SessionBean1.selectedContact.organization.organizationName}" <=== property of property

In the table component, the current row is also a Contact object. What I'd like to be able to do is:

   text="#{currentRow.value['organization.organizationName']}"

Instead, I have to define getOrganizationName in the Contact POJO which returns organization.getOrganizationName(). The binding in the table becomes:

    text="#{currentRow.value['organizationName']}"

Manuel Mall-2 wrote:
One possibility is to define a View at database level containing all the
fields you want and map that to a JPA entity. But I agree it could be argued
that this is also a form of duplication.
Any ads or links to ads that appear in this post are not endorsed nor recommended by this poster.

 « Return to Thread: Displaying related data from JPA query in JSF table component