primefaces tabView activeIndex 问题
我有 Primefaces TabView 和两个选项卡,如下所示:
<p:tabView dynamic="true" cache="false"
onTabShow="scrollBottom(#{stanzaBean.activeIndex})"
tabChangeListener="#{messaggioBean.onTabChange}"
activeIndex="#{stanzaBean.activeIndex}" >
它工作正常,除了当我更改选项卡时,activeIndex 不会在服务器上更新,并且它始终返回默认值。 我正在使用 primefaces 2.2.1。
谢谢。
I have Primefaces TabView with two Tab like:
<p:tabView dynamic="true" cache="false"
onTabShow="scrollBottom(#{stanzaBean.activeIndex})"
tabChangeListener="#{messaggioBean.onTabChange}"
activeIndex="#{stanzaBean.activeIndex}" >
it works fine, except that when I change the Tab the activeIndex isn't updated on the Server and it returns always the default value.
I'm using primefaces 2.2.1.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
按照 PrimeFaces ShowCase 示例,如果您为每个选项卡指定一个 id:
您可以在 tabChangeListener 中获取该选项卡 id。
然后您就会知道选择了哪个选项卡。
编辑:
有一个开放的 PrimeFaces 问题 1640 TabView:TabChangeListener 中的 activeIndex 错误,始终为 0 关于您遇到的问题。
编辑 2:
在 PrimeFaces 5.0 及更高版本中,
tabChangeListener
在tabView
元素上不再可用,但应通过带有 tabChange 事件的显式 ajax 标记来使用。您还可以直接获取选项卡的索引:
通过所有这些更改,activeIndex 可以正常工作。
Going by the PrimeFaces ShowCase example, if you give each tab an id:
you can get that tab id in the tabChangeListener.
Then you'll know which tab was selected.
Edit:
There is an open PrimeFaces issue 1640 TabView: Wrong activeIndex in TabChangeListener, always 0 on the problem you are having.
Edit 2:
With PrimeFaces 5.0 and up the
tabChangeListener
is no longer available on thetabView
element but should be used via an explicit ajax tag with a tabChange event.Also you can directly get index of tab:
with all these changes, activeIndex works properly.
这对我有用:
this worked for me:
虽然问题与 PrimeFaces 2.2.1 有关,但我想提一下,在现代 PrimeFaces 版本(使用版本 6.2 进行测试)中,当属性
dynamic
设置为时,不需要触发单独的事件>true
和cache
设置为false
。通过使用此属性组合,当选择另一个选项卡时,活动索引会在服务器上自动更新。Facelet:
Bean:
Although the question was related to PrimeFaces 2.2.1, I like to mention that in modern PrimeFaces versions (tested with version 6.2) there is no need to trigger a separate event when attribute
dynamic
is set totrue
andcache
is set tofalse
. By using this attribute combination the active index is automatically updated on the server when another tab is selected.Facelet:
Bean: