/** @param silent whether NOT to throw an exception if not found. */ private boolean resolveGroup(boolean silent) { if (_groupId != null) { _group = (Radiogroup) Utils.getComponentById(this, _groupId); if (_group == null) { if (!silent) throw new WrongValueException("Radiogroup not found: " + _groupId); return false; } _groupId = null; _group.addExternal(this); _attachExternal = true; } return true; }
/** 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); } }
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; } } } }