javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-3101

selectBooleanCheckbox in ui repeat does not work

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.2.4
    • Fix Version/s: 2.2.5
    • Component/s: facelets
    • Labels:
      None
    • Environment:

      Tomcat 7, jsf 2.2.4

      Description

      I have an object with boolean property. I Tried to edit a list of them under UI:Repeat. Checkbox is always false/unchecked. Under h:datatbaseTable, checkbox is shown correctly. An example is below.

      package jason.test.chxtest;
      
      import java.io.Serializable;
      
      
      public class Checkbox  implements Serializable{
      
      	/**
      	 * 
      	 */
      	private static final long serialVersionUID = 1L;
      
      	int id;
      	boolean included;
      	int intValue=4;
      	
      	public Checkbox()
      	{
      		
      	}
      	
      	public Checkbox(int id, boolean included, int value) {
      		super();
      		this.id = id;
      		this.included = included;
      		this.intValue = value;
      	}
      
      	public int getId() {
      		return id;
      	}
      	public void setId(int id) {
      		this.id = id;
      	}
      
      	public boolean isIncluded() {
      		return included;
      	}
      	public void setIncluded(boolean included) {
      		this.included = included;
      	}
      	public int getIntValue() {
      		return intValue;
      	}
      	public void setIntValue(int value) {
      		this.intValue = value;
      	}
      	
      }
      
      package jason.test.chxtest;
      
      import java.io.Serializable;
      import java.util.ArrayList;
      import java.util.List;
      
      
      
      
      import javax.enterprise.context.SessionScoped;
      import javax.inject.Named;
      
      @SessionScoped
      @Named("checkboxes")
      public class Checkboxes implements Serializable{
      
      	
      	/**
      	 * 
      	 */
      	private static final long serialVersionUID = 1L;
      	String name="test";
      	private List<List<Checkbox>> listofList=new ArrayList<List<Checkbox>>();
      	public Checkboxes()
      	{
      		List<Checkbox> list=new ArrayList<Checkbox>(2);
      		list.add(new Checkbox(1, true, 3));
      		list.add(new Checkbox(2, false, 4));
      		list.add(new Checkbox(3, true, 5));
      		listofList.add(list);
      	}
      	public List<List<Checkbox>> getListofList() {
      		return listofList;
      	}
      	public List<Checkbox> getList()
      	{
      		return listofList.get(0);
      	}
      	public String getName() {
      		return name;
      	}
      	public void setName(String name) {
      		this.name = name;
      	}
      	
      	
      	
      }
      
      

      PAGE

      <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://xmlns.jcp.org/jsf/passthrough" xmlns:f="http://xmlns.jcp.org/jsf/core"
      	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
      <h:head>
      </h:head>
      <h:body>
      	<b> Change checkbox and integer value</b>
      	<h1>Form 1: nested UI:repeat</h1>
      	<h:form>
      		<ui:repeat var="list" value="#{checkboxes.listofList}">
      			<ui:repeat var="chk" value="#{list}">
      				<label> <h:selectBooleanCheckbox value="#{chk.included}"></h:selectBooleanCheckbox> A checkbox for id #{chk.id}
      				</label>
      				<h:inputText value="#{chk.intValue}"></h:inputText>
      				<br />
      			</ui:repeat>
      
      		</ui:repeat>
      		<h:commandButton action="checkbox1" value="Submit"></h:commandButton>
      		<h:commandButton action="checkbox" value="Submit and get back self"></h:commandButton>
      	</h:form>
      	<h1>Form 2: not nested UI:repeat</h1>
      	<h:form>
      
      		<ui:repeat var="chk" value="#{checkboxes.list}">
      			<label> <h:selectBooleanCheckbox value="#{chk.included}"></h:selectBooleanCheckbox> A checkbox for id #{chk.id}
      			</label>
      			<h:inputText value="#{chk.intValue}"></h:inputText>
      			<br />
      		</ui:repeat>
      		<h:commandButton action="checkbox1" value="Submit"></h:commandButton>
      		<h:commandButton action="checkbox" value="Submit and get back self"></h:commandButton>
      	</h:form>
      	<h1>Form 3: DataTable</h1>
      	<h:form>
      
      		<h:dataTable var="chk" value="#{checkboxes.list}">
      			<h:column>
      				<label> <h:selectBooleanCheckbox value="#{chk.included}"></h:selectBooleanCheckbox> A checkbox for id #{chk.id}
      				</label>
      			</h:column>
      			<h:column>
      				<h:inputText value="#{chk.intValue}"></h:inputText>
      			</h:column>
      </h:dataTable>
      			<h:commandButton action="checkbox1" value="Submit"></h:commandButton>
      			<h:commandButton action="checkbox" value="Submit and get back self"></h:commandButton>
      	</h:form>
      
      </h:body>
      </html>
      

        Activity

        Hide
        Manfred Riem added a comment -

        The behavior you are requesting is not supported in this version as it requires a change in the spec, see https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1230 Thanks!

        Show
        Manfred Riem added a comment - The behavior you are requesting is not supported in this version as it requires a change in the spec, see https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1230 Thanks!
        Hide
        Woofer added a comment -

        This bug is not fixed in version 2.2.5 as listed, it is still present as originally described.

        Show
        Woofer added a comment - This bug is not fixed in version 2.2.5 as listed, it is still present as originally described.
        Hide
        Paul Khodchenkov added a comment -

        Looks like the same issue as https://java.net/jira/browse/JAVASERVERFACES-3096
        Tomcat 7 uses EL 2.2, however EL 3.0 is required by JSF 2.2

        Show
        Paul Khodchenkov added a comment - Looks like the same issue as https://java.net/jira/browse/JAVASERVERFACES-3096 Tomcat 7 uses EL 2.2, however EL 3.0 is required by JSF 2.2

          People

          • Assignee:
            Manfred Riem
            Reporter:
            jasonzhang2002gmailcom
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: