Flow history and "back"

106 views
Skip to first unread message

Robert Ross

unread,
Mar 18, 2014, 12:03:47 AM3/18/14
to dataf...@googlegroups.com
Given that DataFX Flow keeps context on the flow, is there an option to simply go "back" in the stack to the previous view?  This would be a very nice feature.  One step further would be to have the ability to pull back the history itself for things like a bread crumb bar.

Hendrik Ebbers

unread,
Mar 18, 2014, 3:59:42 AM3/18/14
to dataf...@googlegroups.com
Hi Robert,
can you create an issue about that topic at https://bitbucket.org/datafx/datafx/issues
At the moment there is no go back support in the flow but that is an interessting feature.

Robert Ross

unread,
Mar 18, 2014, 8:22:59 AM3/18/14
to dataf...@googlegroups.com
I will do one better.  I'm working on a sub-class of FlowHandler that might have this feature.  Does that sound like the right approach?

Robert Ross

unread,
Mar 18, 2014, 9:51:28 AM3/18/14
to dataf...@googlegroups.com
To really do this right, I would have liked to add an annotation for FXMLFlowBackAction.  Sadly, this looks like it would require direct modification to ViewFactory or completely replacing ViewFactory since the critical method injectFlow() is private.  I also noticed that the annotation binding only appears to work on JavaFX Button objects?  That's quite limiting considering all the different available widgets.


On Tuesday, March 18, 2014 3:59:42 AM UTC-4, Hendrik Ebbers wrote:

Hendrik Ebbers

unread,
Mar 18, 2014, 9:52:39 AM3/18/14
to dataf...@googlegroups.com
can you post your code?

Robert Ross

unread,
Mar 18, 2014, 9:56:01 AM3/18/14
to dataf...@googlegroups.com
I have attached what I have so far.  This doesn't seem terrible complicated, but I haven't tested it at all yet because I haven't been able to easily link the action to a controller annotation. 
FlowHandlerWithHistory.java

Robert Ross

unread,
Mar 18, 2014, 9:57:54 AM3/18/14
to dataf...@googlegroups.com
Here is my new annotation class.
FXMLFlowBackAction.java

Robert Ross

unread,
Mar 18, 2014, 10:06:02 AM3/18/14
to dataf...@googlegroups.com
Looks like I could also do this pretty easily if the FlowLink allowed access to the Controller class.  However, this is all hidden implementation so I cannot seem to find an easy way to get at the controller class to bind with my new annotation.

Robert Ross

unread,
Mar 18, 2014, 10:32:02 AM3/18/14
to dataf...@googlegroups.com
Scratch that.  The FlowLink contains a reference to the Controller class but not the controller view instance.

Robert Ross

unread,
Mar 18, 2014, 11:06:08 AM3/18/14
to dataf...@googlegroups.com
It isn't super pretty, but I believe I got it working without sub-classing anything but FlowHandler and creating a new annotation.  I have attached my code.
FlowHandlerWithHistory.java
FXMLFlowBackAction.java

Robert Ross

unread,
Mar 18, 2014, 11:06:54 AM3/18/14
to dataf...@googlegroups.com
Note that the only thing missing from this history is the initial view so I can go all the way back to the beginning.  Also not sure how to handle Global Actions yet.

Hendrik Ebbers

unread,
Mar 18, 2014, 11:11:07 AM3/18/14
to dataf...@googlegroups.com
I will have a look at it and merge it in the FlowHandler. Thank you

Robert Ross

unread,
Mar 18, 2014, 11:16:26 AM3/18/14
to dataf...@googlegroups.com
Don't thank me yet.  It could be complete crap.  :)

Hendrik Ebbers

unread,
Apr 17, 2014, 12:43:01 PM4/17/14
to dataf...@googlegroups.com
A back action is part of DataFX 8 preview 2: https://groups.google.com/forum/#!topic/datafx-dev/k4YiLhmtT5s

Robert Ross

unread,
Apr 24, 2014, 12:44:49 PM4/24/14
to dataf...@googlegroups.com
My own implementation ended up being a bit more elaborate than what you have right now, including a bread crumb bar.  Specifically, your current implementation is missing the following features I created and will need to retrofit:
  1. Access to the flow history as an ObservableList.  This can be used to bind to a bread crumb bar for automatic visual representation of history.
  2. The "back" action will take an integer so that you can jump back to any spot in the history, not just the previous view.
  3. The "back" annotation takes an optional parameter for the integer.  See previous feature for why.
  4. An additional "Home" annotation which takes the user back to the first item in the history list.
I have attached my previous implementation which worked quite well in DataFX2 but is now broken with DataFX8.  I am working to investigate how to retrofit and/or why it doesn't currently work.
FlowImplementation.zip

Hendrik Ebbers

unread,
Apr 24, 2014, 1:12:03 PM4/24/14
to dataf...@googlegroups.com
Hi,
some of the features are part of DataFX 8.0b2 and other will follow in 8.0b3. Sadly there is no documentation now. But here are some important tips:

- By adding the BackAction annotation to a Control like a Button the flow will execute a back action once the button is pressed. (Part of 8.0b2)
- The FlowHandler includes the method "ObservableList<ViewHistoryDefinition<?>> getControllerHistory()" that will return a read only list of the complete history. (This will be part of 8.0b3 but is already implemented in the trunk / default branch)
- There will be a method that generate a TreeItem to use the ControlsFX BreadCrumb to show the complete History. (8.0b3 or 8.0b4)
- A HomeAction sounds good. I will implement this for 8.0b3. In addition I can add a value to the BackAction annotation with a default of 1. This value can define the steps to jump back
- With 8.0b3 developers can add metadata to a view. The metadata includes a title and a graphic node to represent the view in a breadcrumb or a TabPane.
- I will have a look at your sources. Maybe I can integrate them. Thanks for sharing :)

Hendrik Ebbers

unread,
Apr 24, 2014, 4:21:18 PM4/24/14
to dataf...@googlegroups.com
I added a sample that shows the view metadata. You can find it in the org.datafx.samples.multitab package of the datafx-samples module.
Reply all
Reply to author
Forward
0 new messages