-
1. Re: rich:tabPanel and switchType
djnose Sep 28, 2011 5:27 AM (in response to djnose)is this such a dump question? Or is it just not possible to render parts of the tab?
I want my getter only be called if i click on the second tab.
How can i manage that easy?
currently i did it like that:
- created a binding variable
- wrote a function which checks the active tab and then gets the list
that looks quite "dirty" and feels like a hack... any better way to do that? What are tabs good for, if they load all data directly without being active?
Some code:
/**
* thats kind of weird, we try to figure out if this tab is really active before we get any Objects from the database.
* We do not want the SQL be executed twice!
* @param tabId
* @return
*/
private boolean checkIfTabIsActive(String tabId) {
List<UIComponent> tabs = routingTabPanel.getChildren();
for (UIComponent component : tabs) {
if (component instanceof UITab) {
UITab tab = (UITab) component;
if (tab.getId().equals(tabId) && tab.isActive()) {
return true;
}
}
}
return false;
}/**
* that part has always been executed before. Even if the page / tab was not active*/
public List<ChimeraRoute> getAllRoutes() {
if (checkIfTabIsActive("route")) {
if (allRoutes == null || allRoutes.isEmpty()) {
allRoutes = getRoutesById(getOperatorId(), false);
}
}
return allRoutes;
}→ and the JSF PAGE
<rich:tabPanel switchType="ajax" id="routingTabPanel" binding="#{routeOperatorBean.routingTabPanel}">
<rich:tab header="Active Routing" id="activeRoute" >
<ui:include src="/Route/operator/operatorActiveRoute.xhtml"/>
</rich:tab>
<rich:tab header="Routing" id="route">
<ui:include src="/Route/operator/operatorRoutes.xhtml"/>
</rich:tab>
<rich:tab header="Feature" id="feature">
<p>Here you would see all features per route</p>
</rich:tab>
</rich:tabPanel>Is there anything "nice" i could do?
Thx