Я хочу просмотреть отчет, используя customerId
.
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, ?, ?);// How to fill?
Я пытался:
BLManager.java
public void report(int custId) throws JRException, FileNotFoundException {
Session session = sessionFactory.openSession();
Criteria criteria = session.createCriteria(Customer.class);
criteria.add(Restrictions.eq("custId", custId));
Customre customer = (Customer) criteria.uniqueResult();
FileInputStream fis = new FileInputStream("src/com/customer/reports/report.jrxml");
BufferedInputStream bis = new BufferedInputStream(fis);
JasperReport jasperReport = (JasperReport) JasperCompileManager.compileReport(bis);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, ?, ?);// How to fill?
JasperViewer.viewReport(jasperPrint, false);
}
Далее я вызвал этот метод на buttonClick
Client Class
@FXML
private void viewReport(ActionEvent e) {
Customer customer = customerTable.getSelectionModel().getSelectedItem();
if (customer != null) {
int custId = customer.getCustId();
try {
bLManager.report(custId);
} catch (FileNotFoundException | JRException ex) {
Logger.getLogger(FollowUpController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}