2017-10-01 22:02 GMT+02:00 Burton Rhodes <burtonrho...@gmail.com>:
> As a followup to my last email, it appears the Struts default design
> pattern for checkboxes (submitting false values with hidden value) is the
> cause.  An easy fix for this would be to allow the developer to override
> this design pattern by a s:checkbox parameter (e.g. requiredValue).  The
> default would be "true" - which keeps backwards compatibility, but by
> setting to "false", the hidden checkbox value would not be created in the
> document.  It seems like this would be an easy and beneficial addition to
> the Struts community.  I don't think the "submit false checkboxes" design
> pattern is necessary or appropriate at all times.
>
> Below is the changed code from the overridden checkbox.ftl.  In this
> example, I simply added an <#if> clause around the <input hidden
> __checkbox> element and checked for a new parameter called "requiredValue"
> (dynamicParameter in this example).  Of course the permanent solution would
> be for "requiredValue" to be an actual parameter of the <s:checkbox> tag.
>
> [checkbox.ftl]
> <!-- Code Snippet -->
> <#if (parameters.dynamicAttributes['requiredValue']!"true")?boolean>
>     <input type="hidden" id="__checkbox_${parameters.id?html}"
> name="__checkbox_${parameters.name?html}"
> value="${parameters.fieldValue?html}"<#rt/>
>     <#if parameters.disabled!false>
>              disabled="disabled"<#rt/>
>     </#if>
>     />
> </#if>
>
> Thoughts?  Any reason this would cause issues elsewhere?

I didn't follow the whole discussion (was off for few days to take few
off-road rides on my dirty bike ;-) but I like your idea, feel free to
fill a ticket in JIRA and put your comments with your sample code
there.

One more question, you have overridden the checkbox.ftl by using this
[1] technic, right?

[1] 
https://struts.apache.org/docs/template-loading.html#TemplateLoading-OverridingTemplates


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to