in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/NavigationPaneRenderer.java [121:290]
protected void renderContent(
FacesContext context,
RenderingContext rc,
UIXHierarchy component,
FacesBean bean
) throws IOException
{
NavItemData navItemData = new NavItemData();
List<UIComponent> nonNavItemList = new ArrayList<UIComponent>();
String renderingHint = _getHint(component, bean);
UIComponent nodeStamp = _getStamp(component);
if (nodeStamp == null)
{
// we aren't stamping, but rather have explicitly defined children:
for(UIComponent child : (List<UIComponent>)component.getChildren())
{
if (child.isRendered())
{
UIXCommand navItem;
if (child instanceof UIXCommand)
{
navItem = (UIXCommand) child;
// collect the information needed to render this nav item:
_collectNavItemData(navItemData, navItem, -1, component);
}
else if(renderingHint == NavigationPaneRenderer._HINT_BAR ||
renderingHint == NavigationPaneRenderer._HINT_BUTTONS)
{
navItemData.addItemData(null);
nonNavItemList.add(child);
}
else
{
// we don't support a non-command child for other hints.
_LOG.severe("ILLEGAL_COMPONENT_HIERARCHY_UIXCOMMAND_EXPECTED");
return;
}
}
}
}
else
{
if (!(nodeStamp instanceof UIXCommand))
{
_LOG.severe("ILLEGAL_COMPONENT_HIERARCHY_UIXCOMMAND_EXPECTED");
return;
}
UIXCommand navStamp = (UIXCommand) nodeStamp;
// we are stamping the children:
// Save the current key
Object oldPath = component.getRowKey();
_setStartDepthPath(component,
((UIXNavigationLevel) component).getLevel());
int componentRowCount = component.getRowCount();
if (componentRowCount != 0)
{
int startIndex = component.getFirst();
int endIndex = TableUtils.getLast(component, startIndex);
for (int i = startIndex; i <= endIndex; i++)
{
component.setRowIndex(i);
if (navStamp.isRendered())
{
// collect the information needed to render this nav item:
_collectNavItemData(navItemData, navStamp, i, component);
}
}
}
// Restore the old path
component.setRowKey(oldPath);
}
// We must loop this second time because we support overlapping items,
// arbitrary child wrappers; we need to know information like being the
// first, the last, or whether nearby another active item.
int visibleItemCount = navItemData.getItemCount();
if (visibleItemCount != 0)
{
// starting outer markup:
ResponseWriter rw = context.getResponseWriter();
boolean isRtl = rc.getLocaleContext().isRightToLeft();
boolean isChoiceHint =
(NavigationPaneRenderer._HINT_CHOICE.equals(renderingHint));
String choiceSelectId = null;
if (isChoiceHint)
{
choiceSelectId = getClientId(context, component) + _CHOICE_SELECT_ID_SUFFIX;
if (isRtl)
{
_renderChoiceButton(context, rc, rw, isRtl, choiceSelectId);
}
else
{
_renderChoiceLabel(context, rc, rw, isRtl, component, bean);
}
rw.startElement("select", null);
rw.writeAttribute("id", choiceSelectId, null);
// For Non-JavaScript browsers, render the name attribute thus it would
// enable the browsers to include the name and value of this element
// in its payLoad.
if ( !supportsScripting(rc) )
{
rw.writeAttribute("name", choiceSelectId, null);
}
renderStyleClass(context, rc,
SkinSelectors.AF_NAVIGATION_LEVEL_CHOICE_OPTIONS_STYLE_CLASS);
if (getDisabled(component, bean))
rw.writeAttribute("disabled", Boolean.TRUE, null);
}
int lastRowIndex = visibleItemCount - 1;
boolean previousActive = false;
int nextActiveIndex = navItemData.getEffectiveActiveIndex() - 1;
Object oldPath = component.getRowKey();
_setStartDepthPath(component,
((UIXNavigationLevel)component).getLevel());
Iterator<UIComponent> iter = nonNavItemList.iterator();
for (int i=0; i<visibleItemCount; i++)
{
Map<String, Object> currentItemData = navItemData.getItemData(i);
//if currentItemData is null,we have a non-command child.
if (currentItemData != null)
{
currentItemData.put("isFirst", (i == 0));
currentItemData.put("isLast", (i == lastRowIndex));
currentItemData.put("previousActive", previousActive);
currentItemData.put("nextActive", (i == nextActiveIndex));
Integer rowIndex = (Integer) currentItemData.get("rowIndex");
if (rowIndex != null)
component.setRowIndex(rowIndex.intValue());
_renderNavigationItem(context, rc, rw, currentItemData,
renderingHint, isRtl);
previousActive =
getBooleanFromProperty(currentItemData.get("isActive"));
}
else
{
renderNonCommandChild(i, context, rc,iter.next(), (i == lastRowIndex), renderingHint);
}
}
component.setRowKey(oldPath);
// Close up any opened choice tags:
if (isChoiceHint)
{
rw.endElement("select");
if (isRtl)
{
_renderChoiceLabel(context, rc, rw, isRtl, component, bean);
}
{
_renderChoiceButton(context, rc, rw, isRtl, choiceSelectId);
}
}
}
}