/** Removes the child radio button in the radio group at the given index. * @return the removed radio button. */ public Radio removeItemAt(int index) { final Radio item = getItemAtIndex(index); if (item != null && !removeExternal(item)) { final Component p = item.getParent(); if (p != null) p.removeChild(item); } return item; }
/** Associates the radiogroup to this radio component. * The radio automatically belongs to the nearest ancestral radiogroup. * Use this method only if the radio group is not one of its ancestors. * @since 5.0.4 */ public void setRadiogroup(Radiogroup radiogroup) { boolean inGroup = _groupId != null; _groupId = null; if (inGroup || radiogroup != _group) { _explictGroup = radiogroup != null; if (_group != null) { _group.removeExternal(this); _attachExternal = false; } _group = radiogroup; //ZK-1073 it's better not to add the external when component is not attached. if (_group != null && getDesktop() != null) { _group.addExternal(this); _attachExternal = true; } smartUpdate("radiogroup", _group); } }
@Override public void onPageDetached(Page page) { super.onPageDetached(page); //B65-ZK-1768 remove the radio from the radiogroup in case it is an external radio final Radiogroup rg = getRadiogroup(); if (rg != null) { rg.removeExternal(this); } // ZK-3818: update selected index in the callback if (!_explictGroup) { _group = null; } Component rootParent = ComponentsCtrl.getRootParent(); if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) { ((ComponentCtrl) rootParent).addCallback(AFTER_CHILD_REMOVED, new Callback<Component>() { public void call(Component rootParent) { rg.fixOnRemove(Radio.this); } }); } }
public void setParent(Component parent) { Radiogroup oldgp = null; if (getParent() != null) oldgp = getRadiogroup(); super.setParent(parent); Radiogroup newgp = null; if (parent != null) newgp = getRadiogroup(); if (oldgp != newgp) { if (oldgp != null) { //removed from the component tree if (_explictGroup && oldgp == _group) { _group.removeExternal(this); _attachExternal = false; } } if (newgp != null) { if (_explictGroup && !_attachExternal && newgp == _group) { _group.addExternal(this); _attachExternal = true; } } } }