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

Radio onPageAttached condition causes onPageAttach to not fix index on parent radiogroup

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 9.6.4
    • 9.6.0, 9.6.1
    • None
    • Security Level: Jimmy

      Steps to Reproduce

      Run fiddle

      https://zkfiddle.org/sample/1bh8for/2-radiogroup-detach-removes-selectedIndex

      click button

      Current Result

      Selected index in radiogroup is set to -1 while detached (because Radio#onPageDetached fires, causes selected index to set to -1 in radiogroup during Radiogroup#fixOnRemove)

       

      Selected index remain -1 after component is reattached (because Radio#onPageAttached fires, but doesn't trigger Radiogroup#fixOnAdd)

      Expected Result

      When reattached to the same radiogroup, the selected radio should trigger radiogroup#fixOnAdd

      Debug Information

      Radiogroup#onPageAttached has following condition to trigger fixOnAdd:

       if (rg != null && rootParent instanceof ComponentCtrl if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) {
      

      https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Radio.java#L299-L300

      will only fire is the radiogroup is not a descendant of the rootParent, or if rootParent is the radiogroup.

      If the radiogroup is a descendant of rootParent (as per fiddle), fixOnAdd doesn't trigger.

      Workaround

      attached java class RadioExt.java.

      deploy globally with lang-addon:

      	<component>
      		<component-name>radio</component-name>
      		<extends>radio</extends>
      		<component-class>org.zkoss.zul.RadioExt</component-class>
      	</component>
      

            DevChu DevChu
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: