java - Controller doesn't call internal function -
i'm trying make java crud mvc application. uses sqlite database. 1 of functions doesn't want work. in function want prepare pdf document contain strings. work when try run function separated class, when put mvc app doesn't work.
the console doesn't show errors, think function doesn't start. suppose parameter problem?
here controller.java
:
public void generuj(){ akcja = new actionlistener() { public void actionperformed(actionevent event) { string[] args = null; pdf.main(args); interfejs.getguzikgeneruj().addactionlistener(akcja); } }; }
here functions.java:
public static void generuj() throws documentexception{ document dokument = new document(); try { pdfwriter.getinstance(dokument, new fileoutputstream("arkusz inwentaryzacyjny.pdf")); dokument.open(); paragraph paragraf = new paragraph(); paragraf.add("arkusz inwentaryzacyjny"); dokument.add(paragraf); dokument.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } }
and working class:
package model; import com.itextpdf.text.document; import com.itextpdf.text.documentexception; import com.itextpdf.text.paragraph; import com.itextpdf.text.pdf.pdfwriter; import java.io.filenotfoundexception; import java.io.fileoutputstream; public class pdf { public static void main(string[] args){ document dokument = new document(); try { pdfwriter.getinstance(dokument, new fileoutputstream("arkusz inwentaryzacyjny.pdf")); dokument.open(); paragraph paragraf = new paragraph(); paragraf.add("arkusz inwentaryzacyjny"); dokument.add(paragraf); dokument.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (documentexception e) { e.printstacktrace(); } } }
i @ minimum re-add exception handler documentexception in event method isn't able open pdf document due applications context.
this maybe reason aren't seeing on console.
public static void generujp() throws documentexception { document dokument = new document(); try { pdfwriter.getinstance(dokument, new fileoutputstream("example.pdf")); dokument.open(); paragraph paragraf = new paragraph(); paragraf.add("arkusz inwentaryzacyjny"); dokument.add(paragraf); dokument.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (documentexception e) { e.printstacktrace(); throw e; } }
i wouldn't add action listener within action. never added. did intend have outside event handler?
public void generuj() { ... akcja = new actionlistener() { public void actionperformed( actionevent event) { string[] args = null; pdf.main(args); //interfejs.getguzikgeneruj().addactionlistener(akcja); } }; // new location... interfejs.getguzikgeneruj().addactionlistener(akcja); }
Comments
Post a Comment