JSF agenda with datatable containing data from different lists

Asked

Viewed 587 times

1

I am making a software in JSF (2.2), primefaces and JPA with the Postgres bank. I need to make a schedule of accounts to pay with the following columns and their data: Column before yesterday with the data: due date, supplier and value. Column yesterday with the data: due date, supplier and value. Column today with the data: due date, supplier and value. Column tomorrow with the data: due date, supplier and value. Column the day after tomorrow with data: due date, supplier and value.

These are various data from different queries. My question is how to perform these queries on a single datatable. How do I know which list to call in the columns.

Those are the doubts.

  • Are they the same object? Or for each column you made a different object?

  • You can bring everything in one query only, and put the respective data according as you want, it will probably be more of an object you will need popular.

  • So I didn’t get to do it because I didn’t know how to present this data. Dai wanted to see how I do to identify the column before yesterday has to receive this object the column yesterday has to receive this object and so on.

1 answer

1

You can create an auxiliary object to use in your datatable, in this object you place the column objects before yesterday, yesterday, etc... So you make a list of these auxiliary objects and put them in the value of your datatable. Then you decide what to put in each column.

  • Then the queries return a list so I did like this: contas1 = new Payed(). listarAgenda("Before yesterday"); contas2 = new Contapagardao(). listarAgenda("Yesterday"); contas3 = new Contapagardao(). listarAgenda("Today"); contas4 = new Contapagardao(). listarAgenda("Tomorrow"); contas5 = new Contapagardao(). listarAgenda("Day after tomorrow"); Would that be it? To add all these lists into a single list as it would be?

  • From the code you showed, it looks like they’re all objects of the same class, so it wouldn’t be a problem to put them on the same list.

  • It would be simpler if each one were a table in the database. For example: accounts, the day before yesterday, yesterday. These tables would have a relationship with the accounts table, so you would make a single query to get all the data

  • @Diegoaugusto In fact, there would be no difference of difficulty between being in multiple tables or being in a single table; Join would be extremely similar.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.