Fix guestbook clear selection button #8403
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it: Per slack discussions, @pdurbin found that the button to clear the selected guestbook (i.e. to return to no guestbook)_on the dataset page/edit terms tab was broken. etc. This PR fixes that. (After discussion with @kcondon, I took a look to make sure this wasn't related to recent changes to accessibility/multilicenses,)
I did not see an issue yet.
Which issue(s) this PR closes:
Closes #2257
Special notes for your reviewer: I can't yet understand if/how this worked originally. The main issue is one I saw in some embargo work making controls in a form interact - changing the state in the backing bean doesn't update the state of the UI widget. In this case, the clear button was setting the guestbook to null on the server but the selected radio button remains selected and hence, when you save, it selects the indicated guestbook resulting in no overall change. Changing the 'update' attribute of the button to refresh the set of radio buttons doesn't have the intended effect of making the radio button state reflect the backing bean. (One can confirm that the radio buttons are getting updated by, for example, printing the Guestbook id within the list of guestbooks. That shows that indeed the backing bean has a null guestbook after the clear button is hit. and that the set of radio buttons has just been updated from the server in the response to the actionListener.)
While there may be a way to force such an update, I took an alternate approach and call the widget's unselectAllRows() method (listed in the PrimeFaces client API guide for the DataTable) in an oncomplete call. That appears to work and seems like a reasonable option if not the only/best one. The PR is basically that one line change.
Suggestions on how to test this: Try to clear the guestbook with the button and verify a) the UI updates to show no radio button selected and that b) after a save that the guestbook is indeed null/no guestbook selected for the dataset.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?:
Additional documentation: