When I click on button nothing happens.
<h:commandButton value="Generate PDF" type="button"
action="#{parseHtml12.createPdf}" />
This button is in XHTML file which I want convert to pdf. Java class code is here :
public class ParseHtml12 {
public static final String DEST = "C:\\Users\\User\\Desktop/report.pdf";
public static final String HTML = "web/data.xhtml";
public static void main(String[] args) throws IOException, DocumentException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ParseHtml12().createPdf(DEST);
}
public void createPdf(String file) throws IOException, DocumentException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
writer.setInitialLeading(12);
document.open();
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new FileInputStream(HTML));
document.close();
}
}
This code is good , only problem is how execute class on button click. When I run class in IDE gives me the result but the problem is that the content in XHTML is dynamic and does not retrieve values.
If I execute class when the value will be filled , this will give me desired result.
UPDATE: When the button is clicked dynamic data disappear. And if I click once again happens like this:
javax.el.PropertyNotFoundException: /data.xhtml @48,45 action="#{parseHtml12.createPdf}": Target Unreachable, identifier 'parseHtml12' resolved to null