setSelectedTab problem
vetalok Dec 2, 2008 7:28 AMHello experts,
there are a big (for me) problem with selectedTab() method.
I have 5 tabs, the last is active:
[img]http://vetalok.ho.com.ua/pics/2008-12-02_134752.jpg[/img]
I'm closing each tab from left to the right clicking on "Close" button, expecting to activate the tab which is at the left (i.e after closing product.3 tab product.2 should be activated).
The problem is that sometimes i have the following error:
Dec 2, 2008 2:00:02 PM org.apache.catalina.core.ApplicationContext log INFO: Tabs:_id9: tab panel [@selectedTab=product.3] has no enabled or rendered tab with such name. Tab: product.filter will be used instead!
My code of rich:tabPanel component:
<rich:tabPanel id="Tabs" switchType="client" binding="#{nodeAndTabDemoBean.tabPanel}" immediate="true" <rich:tab name="product.filter" rendered="true"> </rich:tab> <rich:tab rendered="#{nodeAndTabDemoBean.productTabsNum >0}" name="product.0"> <f:facet name="label"> <h:panelGrid columns="2"> <h:outputText value="#{nodeAndTabDemoBean.list[0]}"/> <a4j:commandButton image="/images/close.gif" actionListener="#{nodeAndTabDemoBean.removeTab}" ignoreDupResponses="true" immediate="true" limitToList="true" reRender="Tabs" title="Close" /> </h:panelGrid> </f:facet> </rich:tab> ...
I'm activating tab using binded
private HtmlTabPanel tabPanel = new HtmlTabPanel(); tabPanel.setSelectedTab(name); //here selected tab works but //tab panel [@selectedTab=product.3] has no enabled or rendered tab //with such name. Tab: product.filter will be used instead! //sometimes is appearing
Closed tab does not satisfy the render condition showed above and will not be rendered.
I must use switchType=client for rich:tabPanel tag.
One of the working solution is to use setSelectedTab() of the source tab from the actionEvent object (event.getParent().getTabPanel().setSelectedTab), but it is not suitable in my case, as I need to activate the tab using only the name of it.
I have tried to use other swithTypes, such methods as encodeChildren() and selectedTab attribute of the rich:tabPanel tab but it does not work as I expected.
The reason is that
private HtmlTabPanel tabPanel = new HtmlTabPanel(); tabPanel.setSelectedTab(name);
is ignored while the tab panel is reRender-ed (render response phase)
Any ideas?
Thanks for attention!