JavaFX TableView for SQL database access
My team is evaluating JavaFX as a platform for a database application which will make intense use of TableViews. We are under impression that in order to display data in tables we will have to sub-class TableView and write our own ValueFactory classes for each column data type and presentation mode we are going to need.
For example if we wanted to display bit fields as Yes/No text and on/off checkboxes, we would need 2 ValueFactories or one ValueFactory and two CellFactories for bit data type.
Q1: Is our understanding correct?
Q2: Do any 3d party libraries exist that would allow us to simply set a data binding property of their version of TableView to a ResultSet for example and automatically display data with minor tweaking of display mode?
As evaluation goes on there are more questions arising.
Q3: Willl we have to create a data row class for every SQL query and ObservableList for every class, which would mean that every time we changed returned columns, we would have to re-write data row class? Would we have to implement paging by keeping resultsets in memory and re-populating the ObservableLists on scrolling too?
Q1 - For each column you should specify valueFactory - very easy. If you don't want to show value as default you can specify cellfactory - not so easy. I think best practice is create own class which will extends TableView and you will specify everything you need. You can also create your own TableCell classes etc. I think this work is not so hard in developing javafx app.
Q2 - I don't know but i would create own classes.
Q3 - Observablelist should contain your entity class. Each query should return list of entity objects. Value factory is link with some entity object property.
链接地址: http://www.djcxy.com/p/80142.html