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

Radiogroup getSelectedItem() cause exception if radio are in subcomponents

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 8.5.0
    • Fix Version/s: 8.5.1
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  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