简体   繁体   English

备用Bean中的布尔值未使用Ajax调用更新

[英]Boolean value in backing bean not updated with ajax call

I'm trying to set the value in the backing bean based on the checkbox selection. 我正在尝试基于复选框选择在后备bean中设置值。 Here is the Checkbox: 这是复选框:

...
<f:view>
<p:panel header="HEADER">
    <p:selectBooleanCheckbox id="TEST_CB" itemLabel="TEST CB"
                             value="#{myBB.test}">
        <p:ajax execute="@this" update="someComponent"/>
    </p:selectBooleanCheckbox>
...

In the backing bean, I have a boolean property test with public getter and setter. 在支持bean中,我使用public getter和setter进行了布尔属性test

When I click on the checkbox, the setter in the backing bean is called(so far so good), but the value which is passed as a parameter is always false. 当我单击复选框时,将调用backing bean中的setter(到目前为止很好),但是作为参数传递的值始终为false。 I've been messing with it for two hours, trying different combinations of p:ajax parameters, immediate and partial on the p:selectBooleanCheckbox, I've also tried using h:selectBooleanCheckbox, but it is still false. 我已经搞砸了两个小时,尝试在p:selectBooleanCheckbox上尝试不同的p:ajax参数组合(立即数和局部数),也尝试使用h:selectBooleanCheckbox,但这仍然是错误的。

I use Apache MyFaced 2.1.10 and Primefaces 3.5 我使用Apache MyFaced 2.1.10和Primefaces 3.5

The button was not in the form. 该按钮不在表单中。

After adding <h:form> tag, everything is ok. 添加<h:form>标记后,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM