int selectedTabIndex = getSelectedIndex(container, subPanels);
if (selectedTabIndex == -1)
return; // if there are no rendered items
LoadingMode loadingMode = container.getLoadingMode();
if (loadingMode.equals(LoadingMode.SERVER)) {
encodePageContent(context, container, subPanels, selectedTabIndex, true, containerClass);
container.setItemRendered(selectedTabIndex, true);
} else if (loadingMode.equals(LoadingMode.CLIENT)) {
for (int i = 0; i < allItemCount; i++) {
boolean thisPageVisible = selectedTabIndex == i;
SubPanel subPanel = subPanels.get(i);
if (subPanel.isRendered())
encodePageContent(context, container, subPanels, i, thisPageVisible, containerClass);
container.setItemRendered(i, true);
}
} else if (loadingMode.equals(LoadingMode.AJAX_LAZY)) {
encodePageContent(context, container, subPanels, selectedTabIndex, true, containerClass);
container.setItemRendered(selectedTabIndex, true);
} else if (loadingMode.equals(LoadingMode.AJAX_ALWAYS)) {
encodePageContent(context, container, subPanels, selectedTabIndex, true, containerClass);
container.setItemRendered(selectedTabIndex, true);
} else
throw new IllegalStateException("Invalid loading mode: " + loadingMode);
}