in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/html/layout/CorePanelRadioRenderer.java [130:319]
private void _renderRadioItemsInTD(FacesContext context,
UIComponent component,
ResponseWriter out,
UIXRenderingContext rCtx,
String compId,
String disclosedChildId)
throws IOException
{
out.startElement("td", component);
out.writeAttribute("valign", "top", null);
out.writeAttribute("nowrap", Boolean.TRUE, null);
String formName = RenderUtils.getFormId(context, component);
// each of the radio buttons would occupy a td in a tr
// so there will be as many rows as the number of children and each row
// in turn will have only one td - to contain the radio button
out.startElement("table", component);
out.writeAttribute("id", compId + disclosedChildId, null);
out.writeAttribute("summary", "", null);
out.writeAttribute("border", "0", null);
out.writeAttribute("cellspacing", "0", null);
out.writeAttribute("cellpadding", "0", null);
ListIterator<UIComponent> children = component.getChildren().listIterator();
while (children.hasNext())
{
UIComponent child = children.next();
if (! (child instanceof UIXShowDetail) )
{
continue;
// Can't do any thing with non-showDetail children.
}
UIXShowDetail detailItem = (UIXShowDetail) child;
String childClientId = child.getClientId(context);
out.startElement("tr", component);
out.startElement("td", component);
boolean isRTL = BaseLafUtils.isRightToLeft(rCtx);
if (isRTL)
{
out.writeAttribute("align", "right", null);
}
else
{
out.writeAttribute("align", "left", null);
}
out.writeAttribute("valign", "top", null);
out.writeAttribute("nowrap", Boolean.TRUE, null);
out.startElement("span", component);
out.writeAttribute("id",
childClientId + _RADIO_SPAN_SUFFIX_ID_CONST,
null);
Boolean disabledObj =
(Boolean) detailItem.getAttributes().get(
UIConstants.DISABLED_ATTR.getAttributeName());
boolean disabled = false; // by default is enabled.
if (disabledObj != null)
{
disabled = disabledObj.booleanValue();
}
if (! disclosedChildId.equals(childClientId) && (! disabled) )
{
boolean isImmediate = detailItem.isImmediate();
String submitJS = _getRadioSubmitJS(component,
rCtx,
formName,
compId,
childClientId,
isImmediate);
//PH:onclick javascript handler for a HTML SPAN element is not supported
//on PIE, IE Mobile or Blackberry 4.0. Therefore, create onclick
//javascript for non-PDAs only.
if(!CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
out.writeAttribute("onclick", submitJS, null);
}
// render the radio button now
out.startElement("input", component);
out.writeAttribute("id", childClientId, null);
out.writeAttribute("value", childClientId, null);
out.writeAttribute("name", compId, null);
//PH: onclick javascript handler for an INPUT element is supported on a
//PDA. Therefore, create javascript for onclick on an INPUT element
//instead of a SPAN element.
if(CoreRenderer.isPDA(RenderingContext.getCurrentInstance()))
{
boolean isImmediate = detailItem.isImmediate();
String submitJS = _getRadioSubmitJS(component,
rCtx,
formName,
compId,
childClientId,
isImmediate);
out.writeAttribute("onclick", submitJS, null);
}
if (disabled)
{
out.writeAttribute("disabled", Boolean.TRUE, null);
}
out.writeAttribute("type", "radio", null);
if (disclosedChildId.equals(childClientId) )
{
out.writeAttribute("checked", Boolean.TRUE, null);
}
out.endElement("input");
out.startElement("label", component);
out.writeAttribute("for", childClientId, null);
Character accessChar =
(Character) detailItem.getAttributes().get("accessKey");
if (accessChar != null)
{
out.writeAttribute("accessKey", accessChar.toString(), null);
}
out.startElement("span", component);
String radioSpanClass = getFieldTextClass();
if (disabled)
{
radioSpanClass = SkinSelectors.AF_FIELD_TEXT_DISABLED_STYLE_CLASS;
}
XhtmlLafRenderer.renderStyleClassAttribute(rCtx,
radioSpanClass);
writeLabel(out,
detailItem,
(String) detailItem.getAttributes().get("text"));
out.endElement("span");
out.endElement("label");
out.endElement("span");
out.endElement("td");
out.endElement("tr");
}
// For Non-JavaScript browsers, render a input element(type= submit) to
// submit the page. Encode the name attribute with the parameter name
// and value thus it would enable the browsers to include the name of
// this element in its payLoad if it submits the page.
if (!XhtmlRenderer.supportsScripting
(RenderingContext.getCurrentInstance()))
{
out.startElement("tr", component);
out.startElement("td", component);
if (BaseLafUtils.isRightToLeft(rCtx))
{
out.writeAttribute("align", "right", null);
}
else
{
out.writeAttribute("align", "left", null);
}
out.writeAttribute("valign", "top", null);
out.writeAttribute("nowrap", Boolean.TRUE, null);
String nameAttri = XhtmlUtils.getEncodedParameter
(XhtmlConstants.MULTIPLE_VALUE_PARAM)
+ XhtmlUtils.getEncodedParameter(compId)
+ XhtmlUtils.getEncodedParameter
(XhtmlConstants.EVENT_PARAM)
+ XhtmlConstants.SHOW_EVENT;
out.startElement("span", null);
out.startElement("input", null);
out.writeAttribute("value",XhtmlConstants.NO_JS_PARAMETER_KEY_BUTTON , null);
out.writeAttribute("type","submit", null);
out.writeAttribute("name", nameAttri, null);
out.endElement("input");
out.endElement("span");
out.endElement("td");
out.endElement("tr");
}
out.endElement("table");
out.endElement("td");
}