How to pass object list to Subreport?

Asked

Viewed 1,219 times

1

I have the iReport plugin in netbeans. I’ve already set up the classpath to recognize my classes, I take the following steps:

1 - Send object list Boletim for the main report, each report has information from a student. (This part works, I can generate the data).

2 - Send the 7 lists of notes to the subreport, inside the object Boletim has an object Bimonthly1, Bim2, B3, B4, Examination, Media Anual and Media Final who are of the type Bimestre. Each Bimestre has a list of Notas, Each note has the attributes of matter name, note and missing.

I need to send all note lists to subreport.

So I need to send the lists this way to the subreport

boletim.getBimestre1().getNotas(); //List<Nota>
boletim.getBimestre2().getNotas();//List<Nota>
boletim.getBimestre3().getNotas(); //List<Nota>
boletim.getBimestre4().getNotas();//List<Nota>
boletim.getExame().getNotas(); //List<Nota>
boletim.getNotasAnuais(); //List<Nota>
boletim.getNotasFinais(); //List<Nota>

All these submitted lists have the same size, for each iteration on banda DETAIL do subreport be accessed the next note of the past lists

Main report - here contains the Newsletter object, where you have the class and student data. Also have the lists of grades, these should be sent to the subreport. inserir a descrição da imagem aqui

My Sub-report (here you should receive the 7 note lists, in order to add the information in the lines below the header, where the cells are blank.) inserir a descrição da imagem aqui

Researching a little of this form all right, but just send a list, I need to send at least 7 lists

2 answers

0

Particularly I don’t like to leave intelligence to Jasper, my suggestion is you create a DTO grade by discipline, and fill this in java.

The idea is that this DTO contains as attributes each of the columns you need in the report.

public class NotaDTO {
    String disciplina;
    Double notaPrimeiroBimestre;
    Double notaSegundoBimestre;
    Double notaTerceiroBimestre;
    Double mediaAnual;
    Double mediaFinal;
    Integer falta;
}

You should then fill in the information on this list (in your case 7) with the information for each discipline/two-month period. This way you would pass only a list of your Noticed as Collection of your subreport.

Note: I suggest you rethink the way you structured your project, because there is no object to represent the Discipline?

  • My first solution was this, but it generates a lot of duplicated data. I don’t see it as the best solution.

  • But this DTO would be a temporary list, not persisted, created at the time the report was generated, in order to facilitate the work of Jasper.

0

Dude, if it’s any help yet, I made this tutorial for what you need: Report Tutorial with subelatories in this case I had a subreport within a list, plus if this in your main report, the steps are the same.

Browser other questions tagged

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