/** Returns whether it is selected. * <p>Default: false. * <p>Don't override this. Override {@link #isChecked} instead. */ public boolean isSelected() { return isChecked(); }
public void render(final Radio item, final Object data, final int index) throws Exception { final Radiogroup cb = (Radiogroup) item.getParent(); final Template tm = cb.getTemplate("model"); if (tm == null) { item.setLabel(Objects.toString(data)); item.setValue(data); } else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(item.getParent(), item, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) { if (nci.getValue() == null) //template might set it nci.setValue(data); item.setAttribute(Attributes.MODEL_RENDERAS, nci); item.detach();
public Object coerceToBean(Object val, Component comp, BindContext ctx) { if (val != null) { final ListModel<?> model = ((Radio) val).getRadiogroup().getModel(); if (model != null && !(model instanceof Selectable)) { throw new UiException("model doesn't implement Selectable"); } if (model != null) { Set<?> selection = ((Selectable<?>) model).getSelection(); if (selection == null || selection.size() == 0) return null; return selection.iterator().next(); } else { //no model return ((Radio) val).getValue(); } } return null; } }
/** Sets the radio is checked and unchecked the others in the same radio * group ({@link Radiogroup}. */ public void setChecked(boolean checked) { if (checked != isChecked()) { super.setChecked(checked); fixSiblings(checked, false); } }
/** Called when a radio is added to this group. */ /*package*/ void fixOnAdd(Radio child, boolean external) { if (external && _jsel >= 0 && child.isSelected()) { child.setSelected(false); //it will call fixSelectedIndex } else { fixSelectedIndex(); } }
public void render(final Radio item, final Object data, final int index) throws Exception { final Radiogroup radiogroup = item.getRadiogroup(); final int size = radiogroup.getModel().getSize(); final Template tm = resolveTemplate(radiogroup, item, data, index, size, "model"); if (tm == null) { item.setLabel(Objects.toString(data)); item.setValue(data); } else { final ForEachStatus iterStatus = new AbstractForEachStatus() { //provide iteration status in this context nr.setAttribute(BinderCtrl.VAR, varnm); // for the converter to get the value nr.setAttribute(AbstractRenderer.IS_TEMPLATE_MODEL_ENABLED_ATTR, true); nr.setAttribute(AbstractRenderer.CURRENT_INDEX_RESOLVER_ATTR, new IndirectBinding(data) { public Binder getBinder() { return BinderUtil.getBinder(nr, true); nr.setAttribute(itervarnm, iterStatus); nr.setAttribute(TemplateResolver.TEMPLATE_OBJECT, item.removeAttribute(TemplateResolver.TEMPLATE_OBJECT)); if (nr.getValue() == null) //template might set it nr.setValue(data); item.setAttribute(Attributes.MODEL_RENDERAS, nr); item.detach();
public Object coerceToBean(Object val, Component comp) { //save return val != null ? ((Radio) val).getValue() : null; } }
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Radio self = (Radio)comp; final String uuid = self.getUuid(); wh.write("<span id=\"").write(uuid).write("\" z.type=\"zul.btn.Radio\"") .write(self.getOuterAttrs()).write(">").write("<input type=\"radio\" id=\"") .write(uuid).write("!real\"").write(self.getInnerAttrs()) .write("/><label for=\"").write(uuid).write("!real\"") .write(self.getLabelAttrs()) .write(" class=\""+self.getZclass()+"-cnt\"") .write(">") .write(self.getImgTag()).write(self.getLabel()) .write("</label>"); if(self.getRadiogroup() != null && self.getRadiogroup().getOrient().equals("vertical")) wh.writeln("<br/>"); wh.write("</span>"); } }
/** * Update controls to reflect the current selection state. * * @param processingUpdate If true, a processing status update has occurred. */ private void updateControls(boolean processingUpdate) { btnAll.setDisabled(isProcessing || model.isEmpty()); btnDelete.setDisabled(isProcessing || !canDeleteSelected()); btnInfoAll.setDisabled(isProcessing || !hasInfoOnly()); btnSelected.setDisabled(isProcessing || model.getSelection().isEmpty()); btnForward.setDisabled(isProcessing || btnSelected.isDisabled()); radAll.setStyle(radAll.isChecked() ? BOLD : NO_BOLD); radPatient.setStyle(radPatient.isChecked() ? BOLD : NO_BOLD); if (processingUpdate) { lstNotification.setDisabled(isProcessing); ZKUtil.disableChildren(lstNotification, isProcessing); } }
/** * Loads form data from the current problem. */ private void loadForm() { if (test != null) { setEventType(test.getEventType()); radRefusal.setDisabled(!radRefusal.isChecked()); radHistorical.setDisabled(!radHistorical.isChecked()); radCurrent.setDisabled(!radCurrent.isChecked()); datEvent.setValue(test.getDate()); ZKUtil.disableChildren(fraHistorical, true); datEvent.setDisabled(true); int reading = NumberUtils.toInt(test.getReading(), -1); spnReading.setValue(reading < 0 ? null : reading); } else { onClick$btnSkinTest(); if (txtSkinTest.getValue().isEmpty()) { close(true); return; } setEventType(EventType.CURRENT); Encounter visit = EncounterContext.getActiveEncounter(); Date date = visit == null ? null : visit.getPeriod().getStart(); datEvent.setValue(DateUtil.stripTime(date == null ? new Date() : date)); } }
/** Deselects all of the currently selected radio buttons and selects * the given radio button. */ public void setSelectedItem(Radio item) { if (item == null) { setSelectedIndex(-1); } else { if (item.getRadiogroup() != this) throw new UiException("Not a child: " + item); item.setSelected(true); } }
/** * Loads the registered lists into the radio group. */ private void initRegisteredLists() { for (IPatientList list : registry) { if (!list.isDisabled()) { Radio radio = new Radio(list.getName()); radio.setAttribute(ATTR_PATIENT_LIST, list); rgrpLists.appendChild(radio); if (list == favorites) { radio.setId("radFavorites"); } } } rgrpLists.setSelectedIndex(0); pendingListItem.add(new PatientListItem(null, txtWaitMessage)); }
int pgsz = subset.getSize(), ofs = 0; for (int j = 0; j < pgsz; ++j) { Radio item = new Radio(); item.applyProperties(); item.setParent(this); final int index = j + ofs; final Object value = subset.getElementAt(index); renderer.render(item, value, index); Object v = item.getAttribute(Attributes.MODEL_RENDERAS); if (v != null) //a new item is created to replace the existent one item = (Radio) v;
/** Returns the name of this radio button. * <p>Don't use this method if your application is purely based * on ZK's event-driven model. * <p>It is readonly, and it is generated automatically * to be the same as its parent's name ({@link Radiogroup#getName}). */ public String getName() { final Radiogroup group = getRadiogroup(); return group != null ? group.getName() : getUuid(); }
/** Make sure only one of them is checked. */ private void fixSiblings(boolean checked, boolean byclient) { final Radiogroup group = getRadiogroup(); if (group != null) { if (checked) { final Radio sib = group.getSelectedItem(); if (sib != null && sib != this) { if (byclient) { sib._checked = false; } else { sib.setChecked(false); //and fixSelectedIndex return; } } } group.fixSelectedIndex(); group.syncSelectionToModel(); } }
@SuppressWarnings("unchecked") private void render(Radio item, Object value, int index) throws Throwable { if (!_rendered && (_renderer instanceof RendererCtrl)) { ((RendererCtrl) _renderer).doTry(); _ctrled = true; } try { _renderer.render(item, value, index); } catch (Throwable ex) { try { item.setLabel(Exceptions.getMessage(ex)); } catch (Throwable t) { log.error("", t); } throw ex; } _rendered = true; }
public void onFocus$txtOther() { radOther.setSelected(true); clearMessages(); }
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; } } } }