Griffon : How to open a new window from main view?

163 Views Asked by At

I am new to griffon and trying to develop a griffon app. I want to open secondary window from main window. When the "next" button clicked the secondary window should be open.

config.properties

application.title = Installation Wizard

application.startupGroups = mainWindow

application.autoShutdown = true

mvcGroups.mainWindow.model = com.install.gui.MainGuiModel

mvcGroups.mainWindow.view = com.install.gui.MainGuiView

mvcGroups.mainWindow.controller = com.install.gui.MainGuiController

mvcGroups.secondaryWindow.model = com.install.gui.SecondaryGuiModel

mvcGroups.secondaryWindow.view = com.install.gui.SecondaryGuiView

mvcGroups.secondaryWindow.controller = com.install.gui.SecondaryController

MainGuiController.java:

@ArtifactProviderFor(GriffonController.class)
public class MainGuiController extends AbstractGriffonController {

    private MainGuiModel model;

    public void setModel(MainGuiModel model) {

        this.model = model;

    }

    @Threading(Threading.Policy.INSIDE_UITHREAD_ASYNC)

    public void click() {

        model.setClickCount(model.getClickCount() + 1);

        getApplication().getWindowManager().show("secondaryWindow");

    }

}

the click method is fired when I clicked next button. The click count label is increased. But the second line which is used to open the secondary window is not working.

1

There are 1 best solutions below

0
On

You must create an instance of the secondaryWindow MVCGroup first. Assuming that SecondaryWindowView defines a Stage/Window that's attached to the WndowManager using the window name secondaryWindow then the following should work

public void click() {
    createMVCGroup("secondaryWindow");
    getApplication().getWindowManager().show("secondaryWindow");
}