我想问一个问题,有没有办法更新标签标题,尤其是在p:ajax event =" tabClose"? 因为当我尝试使用此ajax事件更新组件时,标题已更改但标签未关闭且组件卡住。 这是手风琴专家组的代码。
<p:accordionPanel id="searchEmployeeAccordionPanelId"
widgetVar="searchEmployeeAccordionPanelId"
dynamic="true"
cache="true"
activeIndex="#{Employee.accordionIndex}"
style="margin-left: #{Employee.searchEmployeeDataTablePanelRendered ? '20%':''}">
<p:ajax event="tabChange"
listener="#{Employee.tabChangeSearchEmployeeAction}"
update="@([id$=searchEmployeeAccordionPanelId])"
global="false"/>
<p:ajax event="tabClose"
listener="#{Employee.tabCloseSearchEmployeeAction}"
update="@([id$=searchEmployeeAccordionPanelId])" />
<p:tab id="tabTitleId" title="#{Employee.showSearchPanelGridLink}" >
<h:panelGrid id="searchEmployeePanelGridId"
rendered="#{Employee.searchEmployeePanelGridRendered}">
</h:panelGrid>
</p:tab>
</p:accordionPanel>
以下是tabClose ajax事件监听器的代码。
public String tabCloseSearchEmployeeAction(TabCloseEvent event) {
String activeIndex = ((AccordionPanel) event.getComponent()).getActiveIndex();
if (activeIndex.equalsIgnoreCase("0"))
{
event.getTab().setTitle(showSearchLabel);
showSearchPanelGridLink = event.getTab().getTitle();
}
return null;
}
以下是tabChange ajax事件监听器的代码。
public String tabChangeSearchEmployeeAction(TabChangeEvent event) {
String activeIndex = ((AccordionPanel) event.getComponent()).getActiveIndex();
if (activeIndex.equalsIgnoreCase("0"))
{
event.getTab().setTitle(hideSearchLabel);
showSearchPanelGridLink = event.getTab().getTitle();
}
return null;
}
感谢您的帮助。