if (buttonComponent != null && !(buttonComponent instanceof CaptionButton))
throw new FacesException(
"The component inside of \"" + FACET_COLUMN_MENU_BUTTON + "\" facet must be a CaptionButton or descendant component, " +
"though the following component was found: " + buttonComponent.getClass().getName() +
". table id: \"" + table.getClientId(context) + "\"");
CaptionButton button = (CaptionButton) buttonComponent;
boolean temporaryButton = false;
if (button == null) {
button = createDefaultColumnMenuButton(context);
temporaryButton = true;
table.getFacets().put(FACET_COLUMN_MENU_BUTTON, button);
}
if (button.getImageUrl() == null)
button.setImageUrl(getDefaultColumnMenuBtnImage(context));
button.getAttributes().put(CaptionButtonRenderer.ATTR_DEFAULT_STYLE_CLASS, "o_columnMenuInvoker");
// Rendering captionButton.js in this place of the generated HTML markup is required for fixing OF-69.
// The reason is that IE cannot find the <script> tag for captionButton.js via the getElementsByTagName("script")
// call in O$._markPreloadedLibraries (this <script> entry is just missing in this case, which seems to be some
// IE bug) -- the result prior to fix was that ajaxUtil waited for captionButton.js to load indefinitely and failed
// to invoke initialization scripts. Rendering captionButton.js in a less "deep" place of DOM solves the problem.
Resources.renderJSLinkIfNeeded(context, Resources.utilJsURL(context));
Resources.renderJSLinkIfNeeded(context, Resources.internalURL(context, "captionButton.js"));
ResponseWriter writer = context.getResponseWriter();
// mock table/tr enclosing tags must be rendered for IE8 to process the button's td tag properly
writer.startElement("table", table);
writer.startElement("tr", table);
button.encodeAll(context);
writer.endElement("tr");
writer.endElement("table");
PopupMenu columnMenu = (PopupMenu) component;
columnMenu.setStandalone(true);