Nested FXML and bidirectional data binding example - javafx

two days ago I asked for help regarding nested FXML using bidirectional binding of text properties (see Cannot receive user entered data from nested FXML using bindbidirectional binding). Unfortunatly I didn't receive any feedback on this particular problem. Therefore I thought I raise the question in a broader way: Can anybody provide a working example of nested FXML, where the inner controller uses bidirectional binding, ideally to a text property, between the data model and FXML UI controls?
Thank you in advance!

Related

Asp.net bind model strategy for complex data

There is a page like report constructor. On that page a lot of control elements that should help express relationships between different parts of constructor.
Is it normal to have hidden input field with json that helps keep complex relationships, instead of trying prepare N-inputs that will be posted on server and more difficult to map with model.

Qt View/Model/Data Paradigm: How to modify data?

I just read the Model/View documentation for Qt 4.8. I believe to understand how the Model/View (Delegates/SelectionModel) work. One thing that I'm unsure about is how to manipulate data when I have a for example a TreeView.
Imagine having a TreeView to display a list and buttons to remove elements from this list when an item/row is selected. I see two approaches here
1) In the slot of the PushButton I retrieve the SelectionModel and the ItemModel of the TreeView and call model->removeRow(index.row ...). This way the model (that i subclassed from QAbstractItemModel) manipulates the data that it is supposed to represent.
2) In the slot of the PushButton I remove the item directly from the data source, that the TreeView's model represents. Then I can link the data with the model via signals/slot, such that the model can then tell the TreeView that the underlying data has changed.
The same scenario can be imagined with adding elements. Should I add the new element to the data which signals its changed state to the ItemModel which the informs the TreeView, or should I add the new item through the ItemMode?
I haven't found any Best Practices documentation on this. The two approaches differ strongly, such I would like to know in advanced which one is preferable.
Does anybody have a suggestion which path to follow?
Thanks
1) is preferable - you should probably avoid manipulating your data source directly from the UI code - your life will be better if you go through the model. At the very least add a method to your model to do the data manipulation, and call that method from your UI code.
You will find that some of Qt's methods are protected such that they can only be called from the model itself (e.g. endInsertRows etc.)

Setting Closed Nodes for AdvancedDataGrid from a Separate File

I'm trying to set specific closed nodes in my AdvancedDataGrid, and I know you would normally do so using the expandItem() property with the grid. However, I'm obtaining the Hierarchical Data in a separate file, so I'm having difficulty trying to access the data grid from within the adapter file I created for the hierarchical data. Any help would be greatly appreciated.
I found the answer. Apparently, the dataProvider property of the AdvancedDataGrid actually uses the HierarchicalCollection class, so you can use the showItem(); function to access objects that are nodes without having to be in Hierarchical Data.
Example:
AdvancedDataGridName.dataProvider.showItem(object);

MVC architecture development

I have a mobile application that I want to try and reorganize so that it's easier to read and update and follows better practice.
I want to implement an MVC pattern, but I'm getting a little tripped up on getting there. I'm just hoping for some help with rebuilding the architecture.
Here's the outline of my application:
Level1) MainView has a column of 5 buttons that when clicked lead to View1, View2, View3, View4 or View5.
Level2) Each of these views is the same: a list, but each is populated with different data. Selecting an item brings the user to another set of views SubView1 - 20. that each are again populated with a list.
Level3) However, any selection made on a List in a SubView leads to a view that is always the same for all selection paths - but is populated with different data. Basically a button, another list, a text input and a textarea.
From what I gather, I should be able to use a lot less files and achieve something of the same result:
The model being a single class for data? The controller being a class or that controls the business logic, and a view that calls the controller?
Any suggestions, ideas and points in the right direction are greatly appreciated.
I'm guessing you'll be doing this in Flex4 and incorporate MVC pattern to some extent while doing so.
Have you looked into Cairngorm?
http://en.wikipedia.org/wiki/Cairngorm_%28Flex_framework%29

Checkbox in Flex Datagrid Broken on Scrolling

I have a checkbox in a Flex DataGrid, and when I scroll, other rows are randomly checked/unchecked.
After reading over: Creating a column of RadioButtons in Adobe Flex
it's clear that the itemRenderers are getting recycled, but the problem I have with the solution presented there is it moves info about the view into the model.
Does anyone have a better way of solving it, that doesn't force me to put information for the UI into my actionscript model classes? (in my case, I am converting incoming XML data to actionscript classes, and these are getting bound to my datagrid).
Thanks for the help.
thanks everyone. great tips. unfortunately it was becoming too much overhead to keep the model pure, so i just polluted the model like the link in my original post. :( at least it works.
Chetan, neat idea.. i tried working with this for almost an entire day with no luck though.
brd6644, good thoughts on separating the two model classes.. i might go back and do this later.
You could create a subclass of DataGrid that internally stores what rows are checked/unchecked (Array/Collection of Boolean) but you would have a devil of a time keeping that in sync with the dataProvider when it is sorted or filtered. I suppose you could use a Dictionary that is keyed by the object in each index of the dataProvider and valued with a Boolean to indicate whether it's selected. That would at least isolate you from the sorting / filtering issues. This will not work if you have duplicate references in your dataProvider.
Alternatively, you could create a subclass of your ActionScript model class and add the "selected" property to it, then write some simple utility methods to "convert" between the two. That way your View deals only with the "ViewModel" class and other layers (especially the server side) deals only with the real "Model" class.
Adding to what cliff.meyers said, there is a third option of creating a custom IList class as described in this blog post by Alex Harui. It is pretty clever actually, and is cleaner as it doesn't require subclassing the component or polluting your model classes.

Resources