Question

I want to pass a List of objects to one of my functions.

Here's the code:

@RequestMapping(value = "/pages/generateReports")
public ModelAndView toGenerateReports(@ModelAttribute("forReports") @Valid Reports report){    

    List<Patients> patients = patientsDAO.listAllPatients(report.getDateFrom(), report.getDateTo());

    //tried printing what's in patients and surely it contains something

    GenerateReports reports = new GenerateReports();
    reports.generateReports(patients);

    return ...;
}

public class GenerateReports {
    public void generateReports(List<? extends Patients> patients) {

    ....some checkings here and all I get is an empty list... 

    }
}

What do I have to do to make it work?

Was it helpful?

Solution

Your code looks good to me, it should work. You can change List<? extends Patients> patients to List<Patients> patients but that should not change anything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top