DataFX - ApplicationContext

59 views
Skip to first unread message

halim

unread,
Aug 11, 2016, 9:05:00 AM8/11/16
to DataFX
Hi

with ViewFlowContext :  1. create instance (context)
                                    2. add this instance to FlowHandle (Flow flow = ... , FlowHandle handle = flow.createHAndle(context);)
                                    3. inject @FXMLViewFlowContext in each cotroller

all this work fine but .....

with ApplicationContext :  1. craete instance (ApplicationContext context = ApplicationContext.getInstance();  is right ????)
                                      2. thsi is waht i am block for !!! how i can add or use this context in my application ??
                                      3. each controller when use @FXMLApplicationContext context , context always NULL ???

how i can resolve this ????

i use datafx 8.0.1

Bradley Turek

unread,
Feb 26, 2018, 4:03:03 PM2/26/18
to DataFX
I don't know why, but you're right, the @FXMLApplicationContext annotation doesn't seem to work. 

Hendrik, is there a reason for this?

I've been successful by just treating the application context as a singleton and using it like so:

@ViewController(value = "../fxml/MainLayout.fxml", title = "Main Layout")
public class MainLayoutController {

private ApplicationContext applicationContext = ApplicationContext.getInstance();

Object theObjectINeed;

@PostConstruct
public void postConstruct() {
theObjectINeed = applicationContext.getRegisteredObject("theKeyForTheObjectINeed");
}

}
Reply all
Reply to author
Forward
0 new messages