Uploaded image for project: 'Click'
  1. Click
  2. CLK-744

Select control's setValue is not usable due to insufficient wrapping

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 2.3.0-M1, 2.2.0
    • None
    • core
    • None

    Description

      When calling setValue on a Select instance, it bombs out while rendering, regardless whether a String or an Option is passed.

      Passing an Option instance causes it to be 'toString'-ed as an Object (i.e. 'org.apache.click.control.Option@1c154a3') when retrieving the selected value again.

      Passing a String causes it to throw a java.lang.IllegalArgumentException: Select option class not instance of Option or OptionGroup: java.lang.String
      at org.apache.click.control.Select.render(Select.java:998)

      I have modified the render(HtmlStringBuffer buffer) method in Select.java to additionally check for String instances, and in that case wrap it into an Option, and that works fine.

      if (object instanceof String)

      { Option option = new Option(object); option.render(this, buffer); }

      else ...

      The setValue method should probably be overridden from Field to also support the Option case

      Attachments

        1. SelectTestPage.java
          1 kB
          Sander van Grieken

        Activity

          People

            Unassigned Unassigned
            accumulator Sander van Grieken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: