You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by GitBox <gi...@apache.org> on 2022/02/13 09:05:06 UTC

[GitHub] [struts] gregh3269 commented on a change in pull request #531: [WW-5168] Support submit unchecked in Javatemplates and fixes logic for FTL template

gregh3269 commented on a change in pull request #531:
URL: https://github.com/apache/struts/pull/531#discussion_r805303520



##########
File path: plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxHandler.java
##########
@@ -35,29 +36,33 @@ public void generate() throws IOException {
         String id = (String) params.get("id");
         String name = (String) params.get("name");
         Object disabled = params.get("disabled");
+        boolean submitUnchecked = Boolean.parseBoolean(Objects.toString(params.get("submitUnchecked"), "false"));
 
         attrs.add("type", "checkbox")
-                .add("name", name)
-                .add("value", fieldValue)
-                .addIfTrue("checked", params.get("nameValue"))
-                .addIfTrue("readonly", params.get("readonly"))
-                .addIfTrue("disabled", disabled)
-                .addIfExists("tabindex", params.get("tabindex"))
-                .addIfExists("id", id)
-                .addIfExists("class", params.get("cssClass"))
-                .addIfExists("style", params.get("cssStyle"))
-                .addIfExists("title", params.get("title"));
+            .add("name", name)
+            .add("value", fieldValue)
+            .addIfTrue("checked", params.get("nameValue"))
+            .addIfTrue("readonly", params.get("readonly"))
+            .addIfTrue("disabled", disabled)
+            .addIfExists("tabindex", params.get("tabindex"))
+            .addIfExists("id", id)
+            .addIfExists("class", params.get("cssClass"))
+            .addIfExists("style", params.get("cssStyle"))
+            .addIfExists("title", params.get("title"));
         start("input", attrs);
         end("input");
 
-        //hidden input
-        attrs = new Attributes();
-        attrs.add("type", "hidden")
+        if (!submitUnchecked) {

Review comment:
       ..this cold 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).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org