• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Trying to populate data from database in tableview using javafx mvc architecture.  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following code i am trying to populate data from database into tableview using MVC architecture. I am getting a complete row in each column which is not my requirement.
I want to populate tableview with database table as it is.Same code is working fine without MVC architecture in javafx.Please consider the following code.

Controller code is as follows:

model part:

Ranch Hand
Posts: 32
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

first of all you should think about concurrency issues. You are calling the sql statement on the JavaFX Application Thread. Because it could take some time to call the statement the application thread can't handle user interaction or repaint the ui. In this case the application is frozen. Maybe you can check DataFX (www.javafxdata.org) because it handles this issues.

About your problem:
With "col.setCellValueFactory" you define a cell value factory for a column. This factory will extract the item for the column from a data item of the table. The CellDataFeatures that is passed to the lambda expression contains the data item for the current row that is defined by TableView.getItems(). In your example you always return the value (the complete data item). Therefore each cell contains the data item that is defined for the row.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!