How to define flow for changing the content area

333 views
Skip to first unread message

Vijay B

unread,
Mar 9, 2014, 8:24:20 PM3/9/14
to dataf...@googlegroups.com
I am planning to use datafx for a new app that i am building for my client. The application's navigation is controlled by bunch of buttons on the right side of app. Based on button clicked, the center pane (defined as a stack-pane with id: #contentArea) should change.  Can you provide the right direction for defining the flow for my case.

Vijay

Hendrik Ebbers

unread,
Mar 12, 2014, 12:22:42 PM3/12/14
to dataf...@googlegroups.com
The Flow should be handled in the main area (contentArea). You can define global actions for a flow - see Flow.withGlobalLink(....). By doing so you can create actions that link to all your views. the buttons in the menu can call the actions - FlowHandler.handle(....)

Robert Ross

unread,
Mar 17, 2014, 10:26:32 AM3/17/14
to dataf...@googlegroups.com
I find this response a bit confusing.  Flow is not documented very well and there's no examples of using these "Global" methods that I can find.  Can you provide a simple example of of this would work when you have a parent shell FXML that needs to trigger flow behavior on a sub-pane which shows a different FXML?

Hendrik Ebbers

unread,
Mar 17, 2014, 11:05:18 AM3/17/14
to dataf...@googlegroups.com
Hi,

we plan to add JavaDoc and more examples in the next weeks. I will try to add a example the next days that shows how global actions can be used.

Robert Ross

unread,
Mar 17, 2014, 11:29:15 AM3/17/14
to dataf...@googlegroups.com
Vijay, were you able to get this working?  I have to code something up VERY quickly and can't afford to wait a few days for examples.  If you've gotten this working with "Global" actions, can you provide any insight on how this works?

Hendrik Ebbers

unread,
Mar 17, 2014, 11:55:52 AM3/17/14
to dataf...@googlegroups.com
I don't have access to my IDE at the moment but I think something like this should work:


public class GlobalActionsDemo extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        StackPane pane = new StackPane();

        DefaultFlowContainer flowContainer = new DefaultFlowContainer(pane);

        Flow flow = new Flow(ViewController1.class)
                .withGlobalLink("view1ActionId",
                        ViewController1.class)
                .withGlobalLink("view2ActionId",
                        ViewController1.class);

        FlowHandler handler = flow.createHandler();
        handler.start(flowContainer);

        Button b1 = new Button("View 1");
        b1.setOnAction((e) -> handler.handle(("view1ActionId"));

        Button b2 = new Button("View 1");
        b2.setOnAction((e) -> handler.handle(("view2ActionId"));

        VBox box = new VBox();
        box.getChildren().addAll(pane, b1, b2);

        Scene myScene = new Scene(pane);

        stage.setScene(myScene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);

Robert Ross

unread,
Mar 17, 2014, 12:50:15 PM3/17/14
to dataf...@googlegroups.com
Thanks!  I think this explains it pretty well.  The only bug I found in what you just provided is here:

 Scene myScene = new Scene(pane);

This should be:

 Scene myScene = new Scene(box);
Reply all
Reply to author
Forward
0 new messages