Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3818

Radiogroup getSelectedItem() cause exception if radio are in subcomponents

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.5.1
    • 8.5.0
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      Run fiddle
      http://zkfiddle.org/sample/1u8kl6h/2-RadioGroup-index-not-updated-if-radio-is-in-subcomponents

      Click the add button 3 times to add 3 radio buttons.
      Select the 3rd radio.
      Click delete to remove a radio
      Select another radio button

      Current Result

      Exception
      java.lang.IndexOutOfBoundsException: 2 out of 0..1
      at org.zkoss.zul.Radiogroup.getItemAtIndex(Radiogroup.java:140)
      at org.zkoss.zul.Radiogroup.getSelectedItem(Radiogroup.java:215)
      at org.zkoss.zul.Radio.fixSiblings(Radio.java:174)
      at org.zkoss.zul.Radio.service(Radio.java:258)

      Expected Result

      No exception

      Debug Info

      Only happen if the radio are descendant, but not direct children of the radiogroup
      case 2 (direct children) doesn't show the issue

      Root Cause

      _jsel is not updated when removing a descendant radio
      possible additional safety after fix: check if _jsel < radiogroup.getItemCount() in getSelectedItem()

      Workaround

      attached RadioGroup override class for ZK 8.5.0

            bobpeng bobpeng
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour
                1d 1h