【发布时间】:2015-09-29 13:23:05
【问题描述】:
我想通过单击命令按钮来更改选项卡。我正在控制我的 bean 上的 activeIndex 并对 tabView 组件进行更新。一切正常。
我的问题是我想更改 activeIndex 而无需对 tabView 进行更新,因为该组件的更新有点慢。
是否可以通过单击按钮来更改选项卡,而无需更新?
这是我的实际代码。
TabView 组件
<p:tabView id="tvFoo" dynamic="true" activeIndex="#{fooBean.activeIndex}">
<p:tab title="Title" id="someTab">
<ui:include src="someTabName.xhtml" />
</p:tab>
<p:tab title="Title2" id="anotherTab">
<ui:include src="anotherTabName.xhtml" />
</p:tab>
</tabView>
在 someTabName.xhtml 中
<p:commandButton value="go to anotherTab" actionListener="#{fooBean.tabChange('anotherTabName')}" />
fooBean,控制选项卡的变化
public void tabChange(String tabId) {
switch (tabId) {
case "anotherTabName":
activeIndex = 2;
RequestContext.getCurrentInstance().update("tvFoo"); //here is the line that I don't want to call
break;
}
我可以删除那行吗,RequestContext.getCurrentInstance().update("tvFoo");?当然,如果只是删除,选项卡不会改变。
要恢复,基本上我想更改打开的选项卡。我认为我可以手动调用changeTab事件来实现这一点,但我不知道该怎么做。
【问题讨论】:
标签: jsf primefaces tabview