我使用的是primefaces 6.1并在ui:repeat中通过命令按钮创建面板,但是当我将面板属性closable =“ true”与ajax event =“ close”一起使用时,它不会触发所有的getter和setter方法,如果我尝试删除一个创建的面板,当我在创建后备Bean时创建该面板时,该面板不会再次显示,但无法在UI上呈现,倒数第二个面板的相同情况删除了所有创建的分屏器,并且在创建新面板后不恢复显示。
这是xhtml代码:
<p:outputPanel binding="#{chatbotNewsAlertBean.pullMessagesPanel}"
id="pullMessagesPanel">
<ui:repeat value="#{chatbotNewsAlertBean.pullMessages}"
var="pullMessage" varStatus="status">
<p:panel id="pullMessage" toggleable="true" closable="true"
collapsed="true" visible="true"
header="Pull Message #{status.index+1}">
<p:ajax event="close"
listener="#{chatbotNewsAlertBean.onClose(status.index)}" />
</p:panel>
</ui:repeat>
</p:outputPanel>
<p:column style="text-align: right;">
<p:commandButton id="addNewPullMessageButton" value="Add Pull Message"
action="#{chatbotNewsAlertBean.initializeNumberOfForms()}"
update="pullMessagesPanel nextButtonText buttonPosition" />
</p:column>
我的后端bean是:
@ManagedBean(name = "chatbotNewsAlertBean")
@Persistent
@ViewScoped
public class ChatbotNewsAlertManagedBean extends ChatbotNewsAlertBean
{public void initializeSubsurveysList()
{
if (this.getNumberOfPullMessages() == null)
{
this.setNumberOfPullMessages(0);
}
numberOfPullMessages = numberOfPullMessages + 1;
pullMessages.add(new PullMessagesManagedBean());
log.info("PULL MESSAGES SIZE:" + pullMessages.size());
}
/**
* thi method will delete single entry from the list of pul messages
*
* @param index
* of the selected pull message to be deleted
*/
public void onClose(int index)
{
pullMessages.remove(index);
numberOfPullMessages = numberOfPullMessages - 1;
log.info("PULL MESSAGES SIZE:" + pullMessages.size() + " DELETING INDEX VLUE AT:" + index);
log.info("PULL MESSAGES SIZE:" + pullMessages.size());
}
}
我不知道为什么这个Ajax调用会导致close事件产生问题。