Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3919

Checkboxlist does not render label tag correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.3.12
    • None

    Description

      Hello,

      Here are the mods to get the label working!

      //Checkbox button section
      Attributes a = new Attributes();
      a.add("type", "checkbox")
      .add("name", name)
      .add("value", itemKeyStr)
      .addIfTrue("checked", checked)
      .addIfTrue("readonly", params.get("readonly"))
      .addIfTrue("disabled", disabled)
      .addIfExists("tabindex", params.get("tabindex"))
      //.addIfExists("id", name + "-" + Integer.toString(cnt++));
      .addIfExists("id", id + "-" + Integer.toString(cnt));  << CHANGED
      start("input", a);
      end("input");
      
      //Label section
      a = new Attributes();
      //a.add("for",id);
      a.add("for",id + "-" + Integer.toString(cnt))  << CHANGED
      .addIfExists("class", params.get("cssClass"))
      .addIfExists("style", params.get("cssStyle"));
      super.start("label", a);
         if (StringUtils.isNotEmpty(itemValueStr))
                          characters(itemValueStr);
                      super.end("label");
      
                      //Hidden input section
                      a = new Attributes();
                      a.add("type", "hidden")
                              .add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
                              .add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
                              .add("value", "")
                              .addIfTrue("disabled", disabled);
                      start("input", a);
                      end("input");
                      super.end("br");
                      stack.pop();
                      
                      cnt++;  // Increment <<< ADDED
      
      

      Cheers Greg

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            ghuber Greg Huber
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: