• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Create Simple Data Maintenance Form - binding Textfields to Result Set Data

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK - coming along in my Java education, and appreciate help I've received here! I have always been a "data centric application" programmer, and I'm really struggling trying to find tutorials on how to do simple (or what should be simple) binding of form controls to data in a ResultSet. Here's what I'm looking to do.

I can successfully retrieve data from my database (PostgreSQL), and store that result set on my form controller. My form is a simple data maintenance form  - let's say an "Employee" form. I have  text fields for first name, last name, and title. I know I can manually set the text of those text fields to equal the corresponding column (of the current row) in my ResultSet, however, got to be a better way right? What I want to do is BIND the value of each textfield to a column of the result set so that anytime I change the row of the result set, all the textfields automatically update, and so that if I type in a textfield, it auto-updates the corresponding row/column in the ResultSet. I'd have Next and Previous buttons on the form to move to the next/prev row and expect the form to refresh accordingly to display the current row's data.

To me - perhaps because of my background, this is the very most basic, "form 101" thing you can do in an application, so I'm surprised I can't find anything with a simple, straightforward tutorial on it? Please help!

THANKS!

 
Rancher
Posts: 517
15
Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an example of simple GUI app accessing a database. It doesn't have the next and previous buttons, but it has a list of data where one can use a up and down arrow-keys to go to the previous or next record: JavaFX List Example
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what you need is property binding.  Each GUI object exposes several properties that can be bound to action events.  In this way I believe you can get the behavior you want.

I've never done it, but I'd be interested in creating a SSCCE (that's a link) at some point.  And you can post your code here, or if it's too much, post a link to your GitHub account, and I and the rest of those here might be able to help you.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a simple JavaFX form that uses bidirectional bindings so that the "row" is displayed and modifications saved while the program is running.

https://github.com/ksnortum/javafx-bindings-demo
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic