How can I use persistence to get results from query as a recordset, I can use directly in a dataTable-Element?

asked 13.01.2014 at 11:53

Richard%20Schmid's gravatar image

Richard Schmid
(suspended)
accept rate: 25%

edited 14.01.2014 at 09:06

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857

Hello Mr. Schmid can you edit the title of the question so that it is more clear what topic this question is about. What is a dataTable-Element? Thanks

(13.01.2014 at 15:49) Reto Weiss ♦♦ Reto%20Weiss's gravatar image

Hello Mr. Weiss,

If I use List basiswerte = ivy.persistence.bestandDatenPersistence.createNativeQuery("select * from basis").getResultList(); I get a list of entity class elements.

What I am looking for is a result as if I would have used a Database Step

(14.01.2014 at 08:54) Reto Weiss ♦♦ Reto%20Weiss's gravatar image

Hello Mr. Schmid

I think the use case you want to implement is to display values of Basis objects in a HTML dialog. I answered to this question and not how to convert a list into a recordset.

(14.01.2014 at 09:08) Reto Weiss ♦♦ Reto%20Weiss's gravatar image

Instead of using a Recordset in the dataTable element in the html user dialog you can use the list returned from persistence directly:

<p:dataTable var="basis" value="#{data.basiswerte}">
  <p:column headerText="XYZ">
    <h:outputText value="#{basis.xyz}"/>
  </p:column>
  <p:column headerText="ABC">
    <h:outputText value="#{basis.abc}"/>
  </p:column>            
</p:dataTable>

It is important that you declare the attribute basiswerte of the data class with generic types e.g.

basiswerte: List<Basis>

so that jsf knows the class of the list entries. You can then access the fields of the Basis class directly in the dataTable. E.g. the field xyz with with #{basis.xyz}.

link

answered 14.01.2014 at 09:05

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×32
×3

Asked: 13.01.2014 at 11:53

Seen: 2,607 times

Last updated: 14.01.2014 at 09:08