0

I am having trouble refreshing data in the Diagnosis table in my application.

Second table (diagnosisTable) is a bound to the first tables collection, because, in database there are two tables, patients and diagnosis, diagnosis table is related to patients table with foreign keys.

Code for the first table is working fine: thelast two lines are refreshing data -- this code is adding data to diagnosis.

Uros
  • 1
  • 2
  • In theory, when the patient row is selected, you need to get the diagnostics for that patient from the database, generate a new `TableModel` around that data and apply it to your second table ... in theory – MadProgrammer Dec 06 '17 at 21:46
  • well thank you, that makes sence, i will keep working around it. Meanwhile i am going to wait for more answers. – Uros Dec 06 '17 at 21:52
  • If I understand your situation, you can load data into each table, the binding happens when you select a row in one table and the other table should change to match the selection. Do you have table change listeners setup to detect the row selection event in the patient table? If so, you should be using that data to requery and fill the table model of the diagnosis table as mentioned by @MadProgrammer. – Michael McKay Dec 06 '17 at 22:26
  • @MichaelMcKay When i click on the patient in the first table the second table shows all the diagnosis about him, that works. But when i add more diagnosis or delete one in that table nothing changes until i restart the application. Thank you – Uros Dec 06 '17 at 23:32
  • When you say nothing changes until you restart the application, what do you mean? Are you able to make a change, see the change but it isn't copied to the database? Or, when you make a change, it is copied to the database but doesn't appear in the table? In the first case, the problem is with the data binding. In the second, with refreshing of the table data. – Michael McKay Dec 07 '17 at 13:25
  • @MichaelMcKay Changes are copied to database, everything works fine but the jTable is not refreshed. Have in mind that this is persistence application and the elements are bound through the UI, not jdbc statements. Thank you – Uros Dec 07 '17 at 17:15
  • @Delke See https://stackoverflow.com/questions/3179136/jtable-how-to-refresh-table-model-after-insert-delete-or-update-the-data. – Michael McKay Dec 07 '17 at 20:56

0 Answers0