问题描述
还有,当我试图动态生成的支持bean标签出现的一个问题。的问题是,在出现的下拉消失对于每个选择,但标签被正确地更新。是否有解决方法吗?
<电话号码:selectCheckboxMenu值=#{formBean.selectedMovies}标签=#{formBean.moviesLabel} ID =电影> < F:selectItems的值=#{formBean.movies}>< / F:selectItems的> <电话号码:AJAX更新=电影监听器=#{formBean.populateLabel}>< / P:AJAX>< / P:selectCheckboxMenu>
和
//备份豆
公共无效populateLabel(){
/ *与所选的选项填充标签* /
moviesLabel =新的String();
如果(selectedMovies.size()== 0){
moviesLabel =选择;
} 其他 {
的for(int i = 0; I< selectedMovies.size();我++){
如果(moviesLabel.length()== 0){
moviesLabel = selectedMovies.get(ⅰ);
} 其他 {
moviesLabel = moviesLabel +,+ selectedMovies.get(ⅰ);
}
}
}
}
下面是如何
添加 widgetVar =someVarName
您号码:selectCheckboxMenu
和修改号码:加入
的onComplete = AJAX
someVarName.show()
完成code:
<电话号码:selectCheckboxMenu widgetVar =someVarName值=#{usersManagmentPage.selectedMovies}
标签=#{usersManagmentPage.moviesLabel}ID =电影>
< F:selectItems的值=#{usersManagmentPage.movies}>< / F:selectItems的>
<电话号码:阿贾克斯的onComplete =someVarName.show()监听器=#{usersManagmentPage.populateLabel}更新=电影>< / P:AJAX>
< / P:selectCheckboxMenu>
在最新的PrimeFaces 你应该使用的onComplete =PF('someVarName')。显示()
而不是的onComplete =someVarName.show()
There is one problem occurring when I am trying to dynamically generate the label from the backing bean. The problem is that the dropdown that appears vanishes for each selection but the label is updated properly. Is there a workaround for this?
<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>
and
//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);
}
}
}
}
Here is how
add widgetVar="someVarName"
to your p:selectCheckboxMenu
and modify your p:"ajax
by adding oncomplete="someVarName.show()"
complete code :
<p:selectCheckboxMenu widgetVar="someVarName" value="#{usersManagmentPage.selectedMovies}"
label="#{usersManagmentPage.moviesLabel}" id="Movies" >
<f:selectItems value="#{usersManagmentPage.movies}" ></f:selectItems>
<p:ajax oncomplete="someVarName.show()" listener="#{usersManagmentPage.populateLabel}" update="Movies" ></p:ajax>
</p:selectCheckboxMenu>
In latest PrimeFaces you should use oncomplete="PF('someVarName').show()"
instead of oncomplete="someVarName.show()"
这篇关于如何更新p的标签:selectCheckboxMenu没有成分被封闭在primefaces AJAX调用之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!