As newbie in java i wanted to exercise a bit with itext. So far i was able to save my document as pdf with data using a javafx form. I created a table inside my form using a list. But when i wanted to create a table with an observablelist in itext i'm stuck. Can someone help me out and explain why it does work?
In the fxmlDocumentController i declared the following ObservableList.
final ObservableList<ServiceDTO> listServices = FXCollections.observableArrayList();
then i create a actionEvent where i can see that listservices contains some stuff.
@FXML
private void handleButtonCreateInvoice(ActionEvent event) {
InvoicePrint invoice = new InvoicePrint(listServices);
invoice.CreateInvoicePDF();
}
But when it reached my class InvoicePrint it says error cannot access instance variable from static context. So here i'm stuck. Can someone explain me why it doesn't work ?
public InvoicePrint(ObservableList listServices) {
setListServices(listServices);
}
then i want to pass the observablelist to a methode and get all the services data and store it into a table using itext. But it gives me the following error : non-static variable listServices cannot be referenced from a static context.
for (ServiceDTO service : listServices) {
table.addCell(service.getDefinition());
table.addCell(service.getPriceExclVat().toString());
table.addCell(service.getVat().toString());
table.addCell(service.getPriceInclVat().toString());
}