next.setOnclick("/**/"); // XXX avoid submit
// all: sub menu to select any tab directly
UICommand all = (UICommand) CreateComponentUtils.createComponent(
facesContext, UICommand.COMPONENT_TYPE, null, "all");
UIMenu menu = (UIMenu) CreateComponentUtils.createComponent(
facesContext, UIMenu.COMPONENT_TYPE, RendererTypes.MENU, "menu");
FacetUtils.setDropDownMenu(all, menu);
int index = 0;
for (UIComponent child : (List<UIComponent>) tabGroup.getChildren()) {
if (child instanceof UITab) {
UITab tab = (UITab) child;
if (tab.isRendered()) {
UIMenuCommand entry = (UIMenuCommand) CreateComponentUtils.createComponent(
facesContext, UIMenuCommand.COMPONENT_TYPE, RendererTypes.MENU_COMMAND, "entry-" + index);
LabelWithAccessKey label = new LabelWithAccessKey(tab);
entry.setLabel(label.getText());
if (tab.isDisabled()) {
entry.setDisabled(true);
} else {
entry.setOnclick(JQueryUtils.selectId(clientId)
+ ".find('.tobago-tab[tabgroupindex=" + index + "]')"
+ ".click();"
+ "if (event.stopPropagation === undefined) { "
+ " event.cancelBubble = true; " // IE
+ "} else { "
+ " event.stopPropagation(); " // other
+ "}"); // todo: register a onclick handler with jQuery
}
menu.getChildren().add(entry);
}
index++;
}
}
UIToolBar toolBar = (UIToolBar) application.createComponent(UIToolBar.COMPONENT_TYPE);