}
List<UIComponent> children = component.getChildren();
int numChildren = children.size();
UIComponent disclosedChild = null;
UIXShowDetail renderableChild = null;
for (int indxChild = 0; indxChild < numChildren ; indxChild++ )
{
UIComponent child = children.get(indxChild);
if (! (child instanceof UIXShowDetail) )
{
continue;
}
UIXShowDetail detailChild = (UIXShowDetail) children.get(indxChild);
if (detailChild.isRendered())
{
// Mark the first renderable child
if (_isItemDisabled(detailChild))
{
continue;
}
if (renderableChild == null)
{
renderableChild = detailChild;
}
if (detailChild.isDisclosed())
{
disclosedChild = detailChild;
// A diclosed child found. return.
break;
}
}
}
// If we have a minimum of 1 disclosed child and none have been disclosed
// yet, disclose the first rendered one:
if ( (disclosedChild == null) && !getDiscloseNone(bean) &&
(renderableChild != null) && !renderableChild.isDisclosedTransient())
{
renderableChild.setDisclosed(true);
}
ResponseWriter out = context.getResponseWriter();
String compId = component.getClientId(context);
out.startElement("div", component);
renderId(context, component);
renderAllAttributes(context, arc, bean);
boolean discloseMany = getDiscloseMany(bean);
boolean discloseNone = getDiscloseNone(bean);
boolean disclosedFixed = false;
if (discloseMany && !discloseNone) // must keep at least one item disclosed
{
// This is a special case where we must determine if we have to fix the
// disclosure state of one of the items.
int disclosedCount = 0;
for (UIComponent child : (List<UIComponent>) component.getChildren())
{
if (!(child instanceof UIXShowDetail) ||
!child.isRendered())
continue;
UIXShowDetail detailItem = (UIXShowDetail) child;
if (detailItem.isDisclosed())
{
disclosedCount++;
if (disclosedCount > 1)
{
break; // we have enough information at this point to stop counting
}
}
}
if (disclosedCount <= 1)
{
disclosedFixed = true;
}
}
boolean childAlreadyRendered = false;
for (UIComponent child : (List<UIComponent>) component.getChildren())
{
if (!(child instanceof UIXShowDetail) ||
!child.isRendered())
continue;
UIXShowDetail detailItem = (UIXShowDetail) child;
boolean disabled = _isItemDisabled(detailItem);
String titleText = (String)
detailItem.getAttributes().get(CoreShowDetailItem.TEXT_KEY.getName());
boolean disclosed = detailItem.isDisclosed();
if (childAlreadyRendered)
{
// The detail child should be disclosed only when all three criteria met
// 1. is marked as disclosed
// 2. is not disabled and
// 3. if a child is not already disclosed. This occurs when more than
// one showDetail child has it's disclosed property set to true.
disclosed = false;
}
// Header renderer section.
out.startElement("div", detailItem);
String detailItemId = detailItem.getClientId(context);
String itemStyleClass;
if (disabled)
itemStyleClass = getHeaderDisabledStyleClass();
else if (disclosed)
itemStyleClass = getHeaderExpandedStyleClass();
else
itemStyleClass = getHeaderCollapsedStyleClass();
renderStyleClass(context, arc, itemStyleClass);
// Render the toolbar component, if any (we use float to keep
// the toolbar on the right - or left, in RTL languages - so
// it has to be rendered first)
UIComponent toolbar = getFacet(detailItem,
CoreShowDetailItem.TOOLBAR_FACET);
if (toolbar != null)
{
out.startElement("div", detailItem);
renderStyleClass(context, arc, SkinSelectors.AF_PANELACCORDION_TOOLBAR_STYLE_CLASS);
encodeChild(context, toolbar);
out.endElement("div");
}
boolean javaScriptSupport = supportsScripting(arc);
if (javaScriptSupport)
{
out.startElement("a", null);
out.writeAttribute("name", detailItemId, null);
}
else
{
// For Non-JavaScript browsers, render an 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.
out.startElement("input", null);
out.writeAttribute("type", "submit", null);
}
renderStyleClass(context, arc,
disabled
? getLinkDisabledStyleClass()
: getLinkEnabledStyleClass());
// If the child is disclosable and enabled...
boolean disclosable =
discloseNone || (! disclosed) || (discloseMany && !disclosedFixed);
if ( disclosable && (! disabled) )
{
boolean isImmediate = detailItem.isImmediate();
String event = disclosed ? "hide" : "show";
if (javaScriptSupport)
{
String onClickHandler = _getFormSubmitScript(component,