in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/LabelAndMessageRenderer.java [199:407]
protected void encodeAll(
FacesContext context,
RenderingContext rc,
UIComponent component,
FacesBean bean
) throws IOException
{
String clientId = component.getClientId(context);
// If we're a leaf component, see if we can skip our rendering
if (isLeafRenderer() && canSkipRendering(rc, clientId))
{
// Except we really do have a "help" facet, so render that one...
UIComponent help = getFacet(component, "help");
if (help != null)
encodeChild(context, help);
return;
}
String saved = rc.getCurrentClientId();
rc.setCurrentClientId(clientId);
boolean isInTable = _isInTable();
if (hasOwnLabel(component, bean) || isInTable)
{
String value = getLabel(component, bean);
FormData fd = rc.getFormData();
if (fd != null)
fd.addLabel(clientId, value);
}
RequestContext requestContext = RequestContext.getCurrentInstance();
boolean needsPanelFormLayout = _isParentPanelForm(context, component);
boolean isInline = (requestContext.getClientValidation() ==
RequestContext.ClientValidation.INLINE);
if (isInTable && !needsPanelFormLayout)
{
ResponseWriter rw = context.getResponseWriter();
delegateRenderer(context, rc, component, bean, _labelInTable);
renderFieldCellContents(context, rc, component, bean);
if (isInline || hasMessage(context, rc, component, bean))
{
rw.startElement("div", null);
rw.endElement("div");
_renderMessageCellContents(context, rc, component, bean);
}
// In the case of narrow-screen PDAs, to reduce the component's width,
// End facet is always rendered below.
renderEndFacetForNarrowPDA(context, rc, component, true);
}
else
{
ResponseWriter rw = context.getResponseWriter();
boolean isLabelStartAligned = _isLabelStartAligned(context,
needsPanelFormLayout);
// need a table if
// 1) panelForm-friendly component with stacked prompt
// 2) not a non-panelForm-friendly component
boolean needsTableTag = !isLabelStartAligned ||
(!needsPanelFormLayout && _needsTableTag(component));
boolean isPIE = Agent.PLATFORM_PPC.equalsIgnoreCase(
rc.getAgent().getPlatformName());
if (needsTableTag)
{
// While handling a PPR response, Windows Mobile cannot DOM replace
// a table element. Wrapping a table element with a div element fixes
// the problem.
if (isPIE)
{
rw.startElement("div", component);
renderId(context, component);
rw.startElement("table", null);
}
else
{
rw.startElement("table", component);
}
// =-=AEW THIS DOESN'T SEEM RIGHT - IT SHOULD GO ON THE INPUT FIELD
// ONLY, RIGHT? Matching UIX 2.2 behavior here.
rw.writeAttribute("title", getShortDesc(component, bean), "title");
if (!isDesktop(rc))
{
// On PDA browsers label and message pair is always
// rendered in full width.
rw.writeAttribute("width", "100%", null);
}
if (!isPIE)
renderId(context, component);
// put the outer style class here, like af_inputText, styleClass,
// inlineStyle, 'state' styles like p_AFDisabled, etc.
renderRootDomElementStyles(context, rc, component, bean);
OutputUtils.renderLayoutTableAttributes(context, rc, "0", null);
}
rw.startElement("tr", null);
if (!needsTableTag)
{
// Render the ID or else the component cannot be PPR-ed in a future update (both the label
// its associated icons, and the field should update if this component is PPR-ed):
renderId(context, component);
// -= Simon =- HACK
// It's ugly, I hate it, but it works and it's better than pushing
// Cannot use a span either because td is not a valid span child.
//rw.startElement("td", component);
//rw.startElement("table", component);
//OutputUtils.renderLayoutTableAttributes(context, rc, "0", null);
//rw.startElement("tbody", component);
//rw.startElement("tr", component);
//renderRootDomElementStyles(context, rc, component, bean);
// Basically, we're screwed unless we specify panelForm to keep a
// class-less container opened to receive the rootDomStyles.
// Even if this is the case we need a way to detect if a new
// element get opened from encodeBetweenLabelAndFieldCells call.
// Since the above option is so ugly, I'll assume that.
// FIXME: That's too strongly coupled to my taste. Even being stuck
// with a parent tr is too strongly coupled to my taste.
renderRootDomElementStyles(context, rc, component, bean);
}
boolean labelExists = (getLabel(component, bean) != null);
_renderLabelCell(context, rc, component, bean, labelExists);
if (!isLabelStartAligned)
{
rw.endElement("tr");
rw.startElement("tr", null);
}
//This part is necessary to make work hspace on tr:tableFormLayout
Map<String, Object> requestMap = context.getExternalContext()
.getRequestMap();
Integer hspaceObject = (Integer) requestMap.get(
"org.apache.myfaces.trinidadinternal.TableFormHspace");
Boolean percentWidthObject = (Boolean) requestMap.get(
"org.apache.myfaces.trinidadinternal.TableFormPercentWidth");
if (hspaceObject != null)
{
rw.startElement("td", null);
if (percentWidthObject != null && percentWidthObject == true)
{
rw.writeAttribute("width", hspaceObject +"%", null);
}
else
{
rw.writeAttribute("width", hspaceObject, null);
}
rw.endElement("td");
}
_renderFieldCell(context, rc, component, bean, labelExists, needsPanelFormLayout, isInline);
rw.endElement("tr");
// End encoding of the non-panelForm-friendly wrappers:
if (!needsPanelFormLayout)
{
if (isInline || hasMessage(context, rc, component, bean))
{
rw.startElement("tr", null);
if (isLabelStartAligned)
{
// We need an empty cell to prevent the label from spanning down into the footer area and
// to make sure the footer appears below the field cell.
rw.startElement("td", null);
rw.endElement("td");
}
rw.startElement("td", null);
renderStyleClass(context, rc,
SkinSelectors.AF_COMPONENT_MESSAGE_CELL_STYLE_CLASS);
_renderMessageCellContents(context, rc, component, bean);
rw.endElement("td");
rw.endElement("tr");
}
}
// In the case of narrow-screen PDAs, to reduce the component's width,
// End facet is always rendered below.
renderEndFacetForNarrowPDA(context, rc, component, false);
if (needsTableTag)
{
rw.endElement("table");
if (isPIE)
rw.endElement("div");
}
}
rc.setCurrentClientId(saved);
}