这个问题可能过于简单和愚蠢,但是,我没有从谷歌那里得到任何有用的信息。
bean类:
public class Foo {
boolean a;
public boolean getA() {
return a;
}
public void setA(boolean a) {
this.a = a;
}
}
页面:
<h:selectBooleanCheckbox value="#{foo.a}" />
我如何将复选框的值写回视图bean中的“a”属性,而不是valueChangeListener?或者一般来说,更新bean属性的推荐方法是什么?
答案 0 :(得分:1)
您只需提交表单即可。例如,使用<h:commandButton />
执行此操作。确保两个标记都在同一个<h:form></h:form>
。
一般来说,每个没有<h:commandSomething
属性的immediate="true"
都会提交表单(并让输入字段的值经过转换,验证和bean更新)。