我在页面上有一个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";
}