return (obj == null ? "" : obj.toString());
}
@Override
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent _component) throws IOException {
AbstractRadio component = (AbstractRadio) _component;
java.lang.String clientId = component.getClientId(context);
final UIComponent targetComponent = getUtils().findComponentFor(component, component.getFor());
final javax.faces.model.SelectItem item = component.getSelectItem(context, targetComponent);
boolean checked = false;
if (targetComponent instanceof javax.faces.component.UIOutput) {
final Object currentValue = ((javax.faces.component.UIOutput) targetComponent).getValue();
final Object itemValue = item.getValue();
checked = itemValue == null ? currentValue == null : itemValue.equals(currentValue);
}
writer.startElement("input", component);
writer.writeAttribute("id", clientId, "id");
writer.writeAttribute("name", getUtils().clientId(context, targetComponent), "name");
writer.writeAttribute("type", "radio", "type");
writer.writeAttribute("value", InputUtils.getConvertedStringValue(context, targetComponent, item.getValue()), "value");
if (checked) {
writer.writeAttribute("checked", "checked", "checked");
}
if (isDisabled(targetComponent) || isReadonly(targetComponent)) {
writer.writeAttribute("disabled", "disabled", "disabled");
}
String targetOnchange = null;
if (targetComponent != null) {
targetOnchange = convertToString(RenderKitUtils.getAttributeAndBehaviorsValue(context, targetComponent,
RenderKitUtils.attributes().generic("onchange", "onchange", "change", "valueChange").first()));
}
String onchange = convertToString(RenderKitUtils.getAttributeAndBehaviorsValue(context, component,
RenderKitUtils.attributes().generic("onchange", "onchange", "change", "valueChange").first()));
if (targetOnchange != null && !targetOnchange.trim().isEmpty()) {
onchange = onchange == null ? targetOnchange : targetOnchange + ";" + onchange;
}
if (onchange != null && onchange.trim().length() > 0) {
writer.writeAttribute("onchange", onchange, "onchange");
}
getUtils().encodeAttributesFromArray(context, component,
new String[]{"accept", "accesskey", "align", "alt", "checked", "dir", "disabled", "lang", "maxlength", "onblur", "onclick", "ondblclick", "onfocus",
"onkeydown", "onkeypress", "onkeyup", "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onselect", "readonly", "size",
"src", "style", "tabindex", "title", "usemap", "xml:lang"});
writer.endElement("input");
if (component.isLabelVisible()) {
writer.startElement("label", component);
writer.writeAttribute("for", clientId, "for");
writer.writeText(convertToString(item.getLabel()), null);
writer.endElement("label");
}