Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table Binding on UPDATE statement

 
Alex Bru
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I am having some difficulty trying to figure out why my JTable (which has a Beans binding) is able to update itself when only an INSERT SQL statement is executed, but not an UPDATE SQL statement.

Here I create the binding:


Here I add an item to the JTable (WORKS!):


Here I try to update the JTable (NOT working!):


My UPDATE SQL statement is found here:



My problem:
Like I said, the problem is that the JTable does not update when the updatePatientPersonal()-method is executed. However, it updates when the addPatient()-method executes. Why?

I hope someone can help me out.
 
Dave Tolls
Ranch Hand
Posts: 2107
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the first question would be, is your UPDATE actually updating anything in the database?
Do you see that log output, or the pop up?

By the way, those long lines make reading the code quite difficult.
 
Alex Bru
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

The update method does, indeed, update the tables (in the database), but not the JTable. I've also checked whether deleting works, and it does as well (AND it updates the JTable).

 
Dave Tolls
Ranch Hand
Posts: 2107
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your patientList contain Patient objects?
If so, does that have a valid equals operator?

I'm trying to remember how the ObservableList works...

Have you logged the contents of the List after you do the addAll?
 
Dave Tolls
Ranch Hand
Posts: 2107
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, there we go.
http://stackoverflow.com/questions/26838183/how-to-monitor-changes-on-objects-contained-in-an-observablelist-javafx

which led me to this:
http://stackoverflow.com/questions/26730034/java-8-observable-list-invalidation-listener-nor-change-listener-is-called-in/26734379#26734379

which looks like what you need to implement.

Essentially your List currently only informs listeners when the structure of the List changes, and not the values of the contents.
 
Alex Bru
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Ah, there we go.
http://stackoverflow.com/questions/26838183/how-to-monitor-changes-on-objects-contained-in-an-observablelist-javafx

which led me to this:
http://stackoverflow.com/questions/26730034/java-8-observable-list-invalidation-listener-nor-change-listener-is-called-in/26734379#26734379

which looks like what you need to implement.

Essentially your List currently only informs listeners when the structure of the List changes, and not the values of the contents.


Created a new thread out of excitement, but I've found an even simpler solution I can certainly live with (and it definitely seems to save me a lot of work too.)

My solution was to make the JTable editable (and all of its cells) while comitting the changes as so:



An explanation for why this works can be found here.

Thank you for your time!
 
Alex Bru
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am so thankful for your suggestion - I have even found a simpler solution to comitting changes in a JTable with a beans binding.

My solution was to make the JTable editable (and all of its cells) while comitting the changes as so:



An explanation for why this works can be found here.

Thank you for your time!
 
Alex Bru
Greenhorn
Posts: 11
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whelp, please merge or close this thread. Meant to answer here: click
 
Henry Wong
author
Marshal
Pie
Posts: 22114
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Bru wrote:Whelp, please merge or close this thread. Meant to answer here: click


Done as requested.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic