【发布时间】:2015-06-07 03:42:55
【问题描述】:
我尝试解决以下问题:我有一组使用ui:repeat 生成的h:selectBooleanCheckbox:
<h:form>
<ui:repeat value="#{uiCheckboxList.list}" var="boxElement" varStatus="i">
<h:selectBooleanCheckbox id="a">
<f:attribute name="value" value="#{boxElement.enabled}"/>
</h:selectBooleanCheckbox>
<h:outputLabel value="#{boxElement.val}" for="a"/>
</ui:repeat>
</h:form>
值和标签的文本存储在数组列表和servlet控件中:
@ManagedBean(name="uiCheckboxList")
@ApplicationScoped
public class CheckBoxListBean implements Serializable {
private ArrayList<BoxTuple> list;
// BoxTyple is class with 2 fields - val (double) and enabled (boolean)
public CheckBoxListBean() {
list = new ArrayList<>();
for(double i = -2.0; i <= 2.0; i += 0.5) {
list.add(new BoxTuple(i, false));
}
// Set first element to true
list.get(0).setEnabled(true);
}
public ArrayList<BoxTuple> getList() {
return list;
}
public void setList(ArrayList<BoxTuple> list) {
this.list = list;
}
我的问题是:当您单击其中一个h:selectBooleanCheckbox 服务器异步发送的请求,其中包含有关已更改框的信息,然后在不重新加载页面的情况下更改另一个框的值。换句话说,我需要了解单选框的行为。也许这听起来很傻,但我需要解决这个问题。我该如何实现?
【问题讨论】: