简体   繁体   English

动态分配属性ID <p:tab> 在jsf中

[英]dynamically assign attribute id to <p:tab> in jsf

I have created tabs dynamically and I am trying to assign it attribute id which is not working.....or any other way to get the title of the clicked tab? 我已经动态创建了标签,并且尝试为它分配不起作用的属性ID .....或其他任何方法来获取单击的标签的标题?

<p:accordionPanel value="#{displayassestDto.getgroups()}" var="d">
    <p:ajax event="tabChange" listener="#{displayassestDto.onTabChange}" update=":form:growl"/>
       <p:tab title="#{d.group}" id="tab_#{d.group}">
           <h:outputLabel value="Helllooo" />
            </p:tab>
</p:accordionPanel>

any other way to get the title of the clicked tab? 还有其他方法来获取单击的标签的标题吗?

Yes, onTabChange can be modified to accept an object of type TabChangeEvent . 是的,可以将onTabChange修改为接受TabChangeEvent类型的对象。 On this object, you can retrieve the tab that fired the event. 在此对象上,您可以检索引发事件的选项卡。 Your code will look something like 您的代码看起来像

       public void onTabChange(TabChangeEvent evt){
            evt.getTab(); // on this tab object returned, you can get the id, title etc
        }

As to why the code you have is not working right now, it's probably because the state of the output of getGroups() is not consistent throughout the request processing. 至于为什么现在的代码现在无法正常工作,可能是因为在整个请求处理过程中, getGroups()的输出状态不一致。 Ensure you're not carrying out any business logic or processing in getGroups() . 确保您不在getGroups()执行任何业务逻辑或处理。 But you really don't need to do any of that. 但是您实际上不需要执行任何操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM