-
Notifications
You must be signed in to change notification settings - Fork 811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WW-5168] Support submit unchecked in Javatemplates and fixes logic for FTL template #531
Conversation
… all FTL template
Coverage increased (+0.007%) to 50.569% when pulling fe7959e on WW-5168-submit-unchecked into f0b24d1 on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. The old behaviour was confusing (CheckboxHandler
seeming to always add a hidden set of attributes, no matter what).
Thanks to the efforts of @gregh3269 and @lukaszlenart , it looks like it should be improved via this PR. 👏
//hidden input | ||
attrs = new Attributes(); | ||
attrs.add("type", "hidden") | ||
if (!submitUnchecked) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @lukaszlenart . In a recent JIRA update, @gregh3269 has indicated that they think the check/flag is inverted here, based on their testing.
So, their recommendation is this line should be: if (submitUnchecked) {
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... right 🤦 I've misleadingly read FTL template <#if parameters.submitUnchecked!false>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..this could be a breaking change (if you use javatemplates), will now need to add submitUnchecked="true" to your tags if you need the unchecked value (npe in your code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So submitUnchecked
should be true
by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<#if parameters.submitUnchecked!false> was added in 2018 (without complaints), so I guess we should match templates and put an upgrade note. Remember it won't send unchecked checkboxes (without the hidden field), so if you are checking for a false you could get a npe (I found this as I have been switching between ftl for testing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you will get NPE in your action when using Boolean
type instead of boolean
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, most likely with a Boolean (mainly use Boolean or String). If you copy the variable straight into your bean without checking first, can also get a not null on the DB.
Fixes WW-5168
Closes #530