我有一个JSF / PrimeFaces 2.x的用户界面与复选框(H:selectOneBooleanCheckbox),它的值会影响其他部件。是这样的:
I have a JSF / PrimeFaces 2.x UI with a check box (h:selectOneBooleanCheckbox) whose value affects other widgets. Something like:
[X] checkbox1
[____|V] combobox1
[X] checkbox2
在checkbox1是假的,对于ComboBox选择的值必须为空,checkbox2也一定是假的。
When checkbox1 is false, the selected value for combobox1 must be null, and checkbox2 must also be false.
我想使用Ajax在检查checkbox1的支持bean设置的值,但我不知道如何添加AJAX支持啊:selectOneBooleanCheckbox
I'd like to use ajax to set the values in the backing bean on check of checkbox1, but I don't know how to add ajax support for a h:selectOneBooleanCheckbox
谁能帮助?谢谢, 罗布
Can anyone help? Thanks, Rob
谷< F:AJAX>
与监听器
在checkbox1方法,由它来完成所需的作业,呈现ComboBox1的和checkbox1。
Nest <f:ajax>
with a listener
method in checkbox1 which does the desired job and renders the combobox1 and checkbox1.
是这样的:
<h:selectBooleanCheckbox value="#{bean.checkbox1}">
<f:ajax listener="#{bean.listener}" render="combobox1 checkbox2" />
<h:selectBooleanCheckbox>
<h:selectOneMenu id="combobox1" value="#{bean.combobox1}">
<f:selectItems ... />
</h:selectOneMenu>
<h:selectBooleanCheckbox id="checkbox2" value="#{bean.checkbox2}" />
与
public void listener() {
if (!checkbox1) {
combobox1 = null;
checkbox2 = false;
}
}
PrimeFaces本身有一个&LT;电话号码:AJAX&GT;
它提供simlilar功能。它仅使用更新
属性,而JSF标准&LT; F:AJAX&GT;
使用渲染
属性。
PrimeFaces itself has a <p:ajax>
which offers simlilar functionality. It only uses update
attribute whereas JSF standard <f:ajax>
uses render
attribute.