0

我在页面上有一个 tabview 并使用 javascript 动态添加选项卡。同时将打开的选项卡名称添加到列表(lstOpenedPages)中。但是关闭一个选项卡,我无法获取此选项卡的名称,该选项卡已关闭以从列表中删除。现在我想阅读 tabview 的剩余选项卡,因为我可以从列表 (lstOpenedPages) 中找到关闭的选项卡。

如何在 Javascript 中获取 tabview 的剩余标签?

xhtml代码

<p:tabView id="tw" widgetVar="tw">  
   <p:ajax event="tabClose" listener="#{MenuBean.onTabClose}"/>
</p:tabView>

<p:menuitem value="#{itemMenu.menuAck}" 
            action="#{MenuBean.OpenPage(itemMenu.pageName)}" 
            ajax="true"
            oncomplete="handleTabViewEvent(args);" 
/>

<script type="text/javascript">
      function handleTabViewEvent(args) {
          alert('Add tab here..');
       }
</script> 

public void OpenPage(String pageName) {
    lstOpenedPages.add(pageName);
}

public void onTabClose(TabCloseEvent event) {  
    FacesContext context = FacesContext.getCurrentInstance();
    TabView tw = (TabView)context.getViewRoot().findComponent("centerForm:tw");
    String s = "I must delete tab here from lstOpenedPages which closed. But event does not give me tab information. It is always null. So I must be delete from javascript";
}
4

0 回答 0