public class ReportView extends ReportDesign implements View{
private final ReportService reportService;
@Autowired
public ReportView(ReportService reportService) {
this.reportService = reportService;
}
@Autowired
private ApplicationContext appContext;
@Override
public void enter(ViewChangeEvent event) {
}
@PostConstruct
public void init() {
JasperReportsPdfView view = new JasperReportsPdfView();
view.setUrl("classpath:/reports/user.jrxml");
view.setApplicationContext(appContext);
Map<String, Object> params = new HashMap<String, Object>();
params.put("datasource", reportService.report());
}
That fully depends on what ‘ReportDesign’ is. If it is a basic layout, you can just call add(view)
(Vaadin 10+) or addComponent(view)
(Vaadin 8). If it is a HTML design, you need to find whatever element in the design the report should go to, and bind that to the java class using the @Id annotation (and then add the view there). Some documentation for Vaadin 10+ and templates can be found [here]
(https://vaadin.com/docs/flow/polymer-templates/tutorial-template-components.html).
Which Vaadin version are you using?
I’m using vaadin 8. It is a basic layout, created with vaadin designer.
OK, the relevant documentation for Vaadin 8 can be found here: [https://vaadin.com/docs/v8/framework/application/application-declarative.html#application.declarative.identifiers]
(https://vaadin.com/docs/v8/framework/application/application-declarative.html#application.declarative.identifiers).
As I mentioned, the design itself needs a wrapper component that you can then add your content to. That wrapper should have an ID specified, that you then use to access the wrapper from Java.