@Override protected int writeTagContent(TagWriter tagWriter) throws JspException { super.writeTagContent(tagWriter); if (!isDisabled()) { // Write out the 'field was present' marker. tagWriter.startTag("input"); tagWriter.writeAttribute("type", "hidden"); String name = WebDataBinder.DEFAULT_FIELD_MARKER_PREFIX + getName(); tagWriter.writeAttribute("name", name); tagWriter.writeAttribute("value", processFieldValue(name, "on", getInputType())); tagWriter.endTag(); } return SKIP_BODY; }
/** * Renders the '{@code input(radio)}' element with the configured {@link #setValue(Object) value}. * Marks the element as checked if the value matches the {@link #getValue bound value}. */ @Override protected int writeTagContent(TagWriter tagWriter) throws JspException { tagWriter.startTag("input"); String id = resolveId(); writeOptionalAttribute(tagWriter, "id", id); writeOptionalAttribute(tagWriter, "name", getName()); writeOptionalAttributes(tagWriter); writeTagDetails(tagWriter); tagWriter.endTag(); Object resolvedLabel = evaluate("label", getLabel()); if (resolvedLabel != null) { tagWriter.startTag("label"); tagWriter.writeAttribute("for", id); tagWriter.appendValue(convertToDisplayString(resolvedLabel)); tagWriter.endTag(); } return SKIP_BODY; }
@Override protected void writeTagDetails(TagWriter tagWriter) throws JspException { tagWriter.writeAttribute("type", getInputType()); Object boundValue = getBoundValue(); Class valueType = getBindStatus().getValueType(); if (Boolean.class.equals(valueType) || boolean.class.equals(valueType)) { // the concrete type may not be a Boolean - can be String if (boundValue instanceof String) { boundValue = Boolean.valueOf((String) boundValue); } Boolean booleanValue = (boundValue != null ? (Boolean) boundValue : Boolean.FALSE); renderFromBoolean(booleanValue, tagWriter); } else { Object value = getValue(); if (value == null) { throw new IllegalArgumentException( "Attribute 'value' is required when binding to non-boolean values"); } Object resolvedValue = (value instanceof String ? evaluate("value", value) : value); renderFromValue(resolvedValue, tagWriter); } }