From 12badef08b08b8a57ee8ec8f16cc3c05f81f12eb Mon Sep 17 00:00:00 2001 From: Andreas Svanberg <andreass@dsv.su.se> Date: Mon, 10 Feb 2025 13:31:54 +0100 Subject: [PATCH] Fix idea table being updated with first meeting information after scheduling What happened was the idea was loaded (the model got attached) without a first meeting, then the first meeting was created separately in a different model. After creating the first meeting the second model had its object updated in place so no call to IModel#setObject was made. Even if it had been called since there was this separation the idea model would not have been updated either way. Implementing #setObject in the FirstMeetingModel (in FirstMeetingPanel) that would update the idea model would not have solved since its #setObject was never called. To get around this we either have to update the idea models object in place (the chosen solution) or detaching it, forcing a reload from the database that would see the newly created first meeting. --- .../se/su/dsv/scipro/firstmeeting/FirstMeetingPanel.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/view/src/main/java/se/su/dsv/scipro/firstmeeting/FirstMeetingPanel.java b/view/src/main/java/se/su/dsv/scipro/firstmeeting/FirstMeetingPanel.java index c7b62f64cd..3158294d42 100644 --- a/view/src/main/java/se/su/dsv/scipro/firstmeeting/FirstMeetingPanel.java +++ b/view/src/main/java/se/su/dsv/scipro/firstmeeting/FirstMeetingPanel.java @@ -169,7 +169,11 @@ public class FirstMeetingPanel extends GenericPanel<Idea> { } private void saveAndNotify() { - firstMeetingRepository.save(getModelObject()); + FirstMeeting saved = firstMeetingRepository.save(getModelObject()); + // After saving the first meeting we have to populate it on the already loaded idea to + // make sure that other places that want to render the first meeting get the correct data. + // An alternative would be to detach the idea model to force a database refresh. + FirstMeetingPanel.this.getModelObject().setFirstMeeting(saved); NotificationSource source = new NotificationSource(); String date = dateService.format(getModelObject().getFirstMeetingDate(), DateStyle.DATETIME); String room = getModelObject().getRoom();