java - @FXMLViewFlowContext Null pointer exception -


i want create javafx application client. found datafx framework , it. have problem @fxmlviewflowcontext because returns null each time when call child fview parent. used lib version 8.0.7 , below codes

  1. i create side view in main controller i18n resource:

    // side controller add links content flow flow sidemenuflow = new flow(sidemenucontroller.class); sidemenuflowhandler = new flowhandler(sidemenuflow, context, common.getviewconfiguration()); drawer.setsidepane(sidemenuflowhandler.start(new animatedflowcontainer(duration.millis(320), containeranimations.swipe_left))); 
  2. and side pane controller

    @fxmlcontroller(value = "/res/fxml/test.fxml") public class sidemenucontroller {     @fxmlviewflowcontext     private viewflowcontext context;       @fxml     private jfxlistview test;       @fxml     @actiontrigger("suppliers")     private jfxbutton suppliers;       @fxml     @actiontrigger("history")     private jfxbutton history;       @fxml     @actiontrigger("barcode")     private jfxbutton barcode;       @fxml     @actiontrigger("settings")     private jfxbutton settings;       @fxml     @actiontrigger("report")     private jfxbutton report;       @fxml     @actiontrigger("users")     private jfxbutton users;       @fxml     @actiontrigger("inventory")     private jfxbutton inventory;       @fxml     @actiontrigger("shops")     private jfxbutton shops;       @fxml     @actiontrigger("calculation")     private jfxbutton calculation;       @postconstruct     public void initialize(){         test.propagatemouseeventstoparent();         system.out.println(context);           flowhandler contentflowhandler = (flowhandler) context.getregisteredobject("contentflowhandler");         flow contentflow = (flow) context.getregisteredobject("contentflow");         bindnodetocontroller(suppliers, supplierscontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(inventory, inventorycontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(users, userscontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(history, historycontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(shops, shopscontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(report, reportcontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(barcode, barcodecontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(calculation, calculationcontroller.class, contentflow, contentflowhandler);         bindnodetocontroller(settings, settingscontroller.class, contentflow, contentflowhandler);     }       private void bindnodetocontroller(node node, class<?> controllerclass, flow flow, flowhandler flowhandler) {         flow.withgloballink(node.getid(), controllerclass);         node.setonmouseclicked((e) -> {             try {                 flowhandler.handle(node.getid());             } catch (exception e1) {                 e1.printstacktrace();             }         });     } } 

when run program nullpointerexception because context never injected. searched did not find solution. try old libraries not help.

finally solved problem. there 2 reasons problem. 1. first 1 related datafx library version. 2. second problem initialize mehtod. when datafx start create controller class instance initialize method called javafx fxmlloader.load() method , happen before init viewflowcontext got nullpointerexception. in other word if use @postconstruct annotation , call method name initialize, me, method called 2 times 1 when new controller class instance created(context has not init yet) , other 1 when @postconstruct method invoked(context has created). correct datafx flow lib 8.0b8 version. checked version lib 8.0.7 nullpointerexception again. changed lib version , ok


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -