[
https://issues.apache.org/jira/browse/WW-5781?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart updated WW-5781:
------------------------------
Description:
{{template/simple/checkboxlist.ftl}} (also used by {{xhtml}}) and
{{template/html5/checkboxlist.ftl}} write {{class}} and {{style}} on each
checkbox themselves (from {{listCssClass}}/{{listCssStyle}}, falling back to
{{cssClass}}/{{cssStyle}}) and then include {{css.ftl}}, which writes {{class}}
and {{style}} again.
Rendering {{<s:checkboxlist name="collection" list="list" listKey="top[0]"
listValue="top[1]" cssClass="myClass" cssStyle="width:150px"/>}} with the
simple theme produces:
{code:html}<input type="checkbox" name="collection" value="hello"
id="collection-1" class="myClass" style="width:150px" class="myClass"
style="width:150px" />
{code}
and with {{listCssClass="'itemClass'"}} added:
{code:html}<input type="checkbox" ... class="itemClass" style="width:150px"
class="myClass" style="width:150px" />
{code}
{{template/simple/radiomap.ftl}} and {{template/html5/radiomap.ftl}} (the
{{s:radio}} tag) have the same defect whenever {{listCssClass}} or
{{listCssStyle}} is set: the item {{class}}/{{style}} is written, then
{{css.ftl}} writes the tag-level ones again.
Duplicate attributes are invalid HTML and browsers keep only the first
occurrence. With field errors present, the {{class="myClass errclass"}} /
{{cssErrorStyle}} value written by {{css.ftl}} comes second and is dropped, so
{{cssErrorClass}} and {{cssErrorStyle}} have no effect on these inputs.
Expected: each checkbox/radio input carries a single {{class}} and a single
{{style}} attribute. {{listCssClass}}/{{listCssStyle}} replace
{{cssClass}}/{{cssStyle}} (what browsers render today), {{cssErrorClass}} is
appended and {{cssErrorStyle}} applied when the field has errors, following the
{{css.ftl}} rules. No existing test covers {{cssClass}} on these inputs.
was:
{{template/simple/checkboxlist.ftl}} (also used by {{xhtml}}) and
{{template/html5/checkboxlist.ftl}} write {{class}} and {{style}} on each
checkbox themselves (from {{listCssClass}}/{{listCssStyle}}, falling back to
{{cssClass}}/{{cssStyle}}) and then include {{css.ftl}}, which writes {{class}}
and {{style}} again.
Rendering {{<s:checkboxlist name="collection" list="list" listKey="top[0]"
listValue="top[1]" cssClass="myClass" cssStyle="width:150px"/>}} with the
simple theme produces:
{code:html}<input type="checkbox" name="collection" value="hello"
id="collection-1" class="myClass" style="width:150px" class="myClass"
style="width:150px" />
{code}
and with {{listCssClass="'itemClass'"}} added:
{code:html}<input type="checkbox" ... class="itemClass" style="width:150px"
class="myClass" style="width:150px" />
{code}
Duplicate attributes are invalid HTML and browsers keep only the first
occurrence. As a consequence, when the field has errors the {{class="myClass
error"}} / {{cssErrorStyle}} value written by {{css.ftl}} comes second and is
dropped, so {{cssErrorClass}} and {{cssErrorStyle}} have no effect on
checkboxlist (follows from the HTML parsing rule; the field-error case was not
rendered).
{{radiomap.ftl}} does not have this problem — it relies on {{css.ftl}} alone
for the input.
Expected: each checkbox carries a single {{class}} and a single {{style}}
attribute; per-item {{listCssClass}}/{{listCssStyle}} take precedence over
{{cssClass}}/{{cssStyle}}, and the error class/style is applied when the field
has errors. No existing test covers {{cssClass}} on the simple-theme
checkboxlist.
> checkboxlist renders class and style attributes twice,
> cssErrorClass/cssErrorStyle never apply
> ----------------------------------------------------------------------------------------------
>
> Key: WW-5781
> URL: https://issues.apache.org/jira/browse/WW-5781
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - Tags
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.5.0
>
>
> {{template/simple/checkboxlist.ftl}} (also used by {{xhtml}}) and
> {{template/html5/checkboxlist.ftl}} write {{class}} and {{style}} on each
> checkbox themselves (from {{listCssClass}}/{{listCssStyle}}, falling back to
> {{cssClass}}/{{cssStyle}}) and then include {{css.ftl}}, which writes
> {{class}} and {{style}} again.
> Rendering {{<s:checkboxlist name="collection" list="list" listKey="top[0]"
> listValue="top[1]" cssClass="myClass" cssStyle="width:150px"/>}} with the
> simple theme produces:
> {code:html}<input type="checkbox" name="collection" value="hello"
> id="collection-1" class="myClass" style="width:150px" class="myClass"
> style="width:150px" />
> {code}
> and with {{listCssClass="'itemClass'"}} added:
> {code:html}<input type="checkbox" ... class="itemClass" style="width:150px"
> class="myClass" style="width:150px" />
> {code}
> {{template/simple/radiomap.ftl}} and {{template/html5/radiomap.ftl}} (the
> {{s:radio}} tag) have the same defect whenever {{listCssClass}} or
> {{listCssStyle}} is set: the item {{class}}/{{style}} is written, then
> {{css.ftl}} writes the tag-level ones again.
> Duplicate attributes are invalid HTML and browsers keep only the first
> occurrence. With field errors present, the {{class="myClass errclass"}} /
> {{cssErrorStyle}} value written by {{css.ftl}} comes second and is dropped,
> so {{cssErrorClass}} and {{cssErrorStyle}} have no effect on these inputs.
> Expected: each checkbox/radio input carries a single {{class}} and a single
> {{style}} attribute. {{listCssClass}}/{{listCssStyle}} replace
> {{cssClass}}/{{cssStyle}} (what browsers render today), {{cssErrorClass}} is
> appended and {{cssErrorStyle}} applied when the field has errors, following
> the {{css.ftl}} rules. No existing test covers {{cssClass}} on these inputs.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)