This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Access Data or Controller via MDI

General questions regarding the development with JavaFX UI for JVx.

Access Data or Controller via MDI

Postby javalearner » Fri Mar 30, 2018 12:39 pm

Not sure if anyone is still active on this forum, but decided to ask anyway.

Just playing with "MDI" using the JVx library.

Been able to get most of my test skeleton working, however I have run into an issue of how to access a model/controller via an "FXInternalWindow"?

ie, I have a "Menu/Toolbar/FXDesktopPane/Footer" style app, which can create new "FXInternalWindow"s, and during the creation, I create my backend Model/Controller and from the controller generate a Group which I can embed with the "FXInternalWindow", but how to I link the "FXInternalWindow" and the controller together efficiently.
The reason behind this, is when I have a window selected, I need to be able to have a button within a toolbar to be able to save the active (or last active, as focus is lost when you click a menu or toolbar) window's model, also to be able to perform various other tasks.

Initially I was thinking of either creating a observable list, with two fields, one with the "FXInternalWindow" reference and one with the controller, so I can find the active window, and compare against the list to get my controller.
Second option was to "extend" "FXInternalWindow" to a custom "FXInternalWindowWithController" and add in the logic to store a reference to the controller etc...

So, just wondering, what is the best way, or is there other "better" ways...

Many thanks in advance.

Posts: 6
Joined: Wed Mar 28, 2018 10:11 am

Re: Access Data or Controller via MDI

Postby rzenz » Fri Mar 30, 2018 2:30 pm

My first intuition would be to extend the FXInternalWindow class and make know about the controller, yes.

However, given that you have said that you "just" embed your content inside the FXInternalWindow, I would actually do it different. You see, in JVx we have support to create such applications as you describe (obviously, what ERP framework wouldn't?). However, our "internal windows" are not windows at all when they are created/coded. They are called "contents", they are only displayed as internal windows when using the MDI application frame. In reality, they are just panels which get embedded into whatever is going to display them. The whole management of these is also not concerned with windows at all, it only manages these contents and the actual implementation of the application is handling the window management.

You can apply the same principle here by not keeping a list of windows, but keeping a list of your window contents, and that content knows about the controller. That way you're decoupled from the presentation of your content and can swap out that layer any time. So what you can try is to create a base pane class from which all your screens will extend, for example ControllerPane. That simple class extends from Pane and adds a way to access the controller with which it (or its content) is associated. In your application, instead of accessing the window list of the FXDesktopPane, you simply keep a list of your ControllerPanes and access these.

That way your screens are decoupled from the way they are presented by your application, just like in JVx. For inspiration, you can have a look at the IWorkScreenApplication which provides a base interface for such mechanics.
User avatar
Posts: 36
Joined: Mon Dec 12, 2016 1:40 pm
Location: Vienna, Austria

Return to Development