Why h:selectBooleanCheckbox not is updated?

35 Views Asked by At

I am developing a Java Web application with JSF 2.2 and I have a list Boolean, but this list not change with the client decisions; when the user does click on h:commandButton the list show every the same result:

false
false
true

My xhtml code is:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <ui:repeat value="#{test.list}" var="item" varStatus="status">
                <h:selectBooleanCheckbox value="#{item}"/>
                Hello #{status.index}
                <br/>
            </ui:repeat>
            <h:commandButton value="write" action="#{test.write}">
                <f:ajax render="@form" execute="@form"/>
            </h:commandButton>
        </h:form>
    </h:body>
</html>

And my Bean is:

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean
@SessionScoped
public class Test implements Serializable {

    private List<Boolean> list;

    public Test() {
        list = new ArrayList();
        list.add(false);
        list.add(false);
        list.add(true);
    }

    public void write(){
        int t = list.size();
        for(int i = 0; i < t; i++)
            System.out.println(list.get(i));
    }

    public List<Boolean> getList() {
        return list;
    }

    public void setList(List<Boolean> list) {
        this.list = list;
    }

}

If user checked on, for example, the first option, when the user does click on the button, the ouput must be:

true
false
true

What is the problem? thank you very much!

0

There are 0 best solutions below