Skip to content
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

Merged
merged 4 commits into from
Feb 20, 2022

Conversation

lukaszlenart
Copy link
Member

@lukaszlenart lukaszlenart commented Feb 9, 2022

Fixes WW-5168

Closes #530

@coveralls
Copy link

coveralls commented Feb 9, 2022

Coverage Status

Coverage increased (+0.007%) to 50.569% when pulling fe7959e on WW-5168-submit-unchecked into f0b24d1 on master.

Copy link
Contributor

@JCgH4164838Gh792C124B5 JCgH4164838Gh792C124B5 left a 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) {
Copy link
Contributor

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.

Copy link
Member Author

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>

Copy link
Contributor

@gregh3269 gregh3269 Feb 13, 2022

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).

Copy link
Member Author

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?

Copy link
Contributor

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).

Copy link
Member Author

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?

Copy link
Contributor

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.

@lukaszlenart lukaszlenart changed the title WW-5168 Support submit unchecked in Javatemplates and fixes logic for FTL template [WW-5168] Support submit unchecked in Javatemplates and fixes logic for FTL template Feb 13, 2022
@lukaszlenart lukaszlenart merged commit 059514d into master Feb 20, 2022
@lukaszlenart lukaszlenart deleted the WW-5168-submit-unchecked branch February 20, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants