Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1797

Bug with default RadioChoice "for" attribute on label generation.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.4-M1
    • 1.3.5, 1.4-RC1
    • wicket
    • None

    Description

      If you use 2 forms of the same name, with radio choice with the same name and values, then the "for" attribute is generated based on the name relative to the current form, and the index of the option.

      This generated incorrect html.

      The behaviour is: when you click on the label of radio items in the second form, the items in the first form are selected.

      For example

      class userdetailspanel extends panel {
      userdetailspanel(string id) {
      super(id)
      Form form = new Form("testForm");
      List SITES = Arrays.asList(new String[]

      { "The Server Side", "Java Lobby" }

      );
      form.add(new RadioChoice("site", SITES));
      }
      }

      class detailspage extends page {
      detailspage()

      { add(new userdetailspanel("panel1")); add(new userdetailspanel("panel2")); }

      }

      This is because of the way the IDs are generated in RadioChoice. Specifically around

      String id = getChoiceRenderer().getIdValue(choice, index);
      final String idAttr = getInputName() + "_" + id;

      A workaround I have has been adding a choice renderer when creating any of these RadioChoices. I have been overriding getIdValue to return something unique. (based off the housing components markupid)

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            ned.collyer Ned Collyer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: