如何在不关闭素数中的ajax调用后关闭组件的情况下更新p:selectCheckboxMenu的标签?
2022-09-03 13:22:34
当我尝试从后备 Bean 动态生成标签时,会出现一个问题。问题是,对于每个选择,显示的下拉列表都会消失,但标签已正确更新。是否有解决此问题的方法?
<p:selectCheckboxMenu value="#{formBean.selectedMovies}" label="#{formBean.moviesLabel}" id="Movies" >
<f:selectItems value="#{formBean.movies}" ></f:selectItems>
<p:ajax update="Movies" listener="#{formBean.populateLabel}"></p:ajax>
</p:selectCheckboxMenu>
和
//Backing bean
public void populateLabel() {
/* Populating the label with the selected options */
moviesLabel = new String("");
if (selectedMovies.size() == 0) {
moviesLabel = "Select";
} else {
for (int i = 0; i < selectedMovies.size(); i++) {
if (moviesLabel.length() == 0) {
moviesLabel = selectedMovies.get(i);
} else {
moviesLabel = moviesLabel + "," + selectedMovies.get(i);
}
}
}
}