Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.8.2
-
Fix Version/s: 1.8.2-EE-GA, 1.8.3
-
Component/s: ICE-Components
-
Labels:None
-
Environment:All
Description
Selecting an odd date (not even) on a selectInputDate triggers validation of the other fields in the page when immediate is set to true. The same thing happens for the "Show previous month" and "Show previous year" buttons. When selecting an even date, "Show next month" or "Show next year" everything works as expected.
main.xhtml
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<head>
<title>Test</title>
<ice:outputStyle href="xmlhttp/css/rime/rime.css" />
</head>
<body>
<ice:form partialSubmit="false" id="Form">
<ice:panelGrid columns="3">
<ice:inputText value="#{bean.text}" id="Text" required="true">
<f:validateLength minimum="2" />
</ice:inputText>
<ice:selectInputDate value="#{bean.date}" renderAsPopup="false" partialSubmit="false" id="Date" immediate="true" />
<ice:selectOneListbox value="#{bean.item}" size="1" required="true" id="Combo">
<f:selectItem itemLabel="Select..." itemValue="-1" />
<f:selectItem itemLabel="0" itemValue="0" />
<f:selectItem itemLabel="1" itemValue="1" />
<f:selectItem itemLabel="2" itemValue="2" />
<f:validateLongRange minimum="0" />
</ice:selectOneListbox>
</ice:panelGrid>
<ice:commandButton actionListener="#{bean.submit}" value="Submit" />
<br />
<ice:outputText value="Text: #{bean.text}<br/>Date: #{bean.date}<br/>Item: #{bean.item}" escape="false" />
</ice:form>
<ice:messages />
</body>
</html>
Bean.java
package org.local.test;
import java.util.Date;
import javax.faces.event.ActionEvent;
public class Bean {
private String text;
private Date date;
private Integer item;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getItem() {
return item;
}
public void setItem(Integer item) {
this.item = item;
}
public void submit(ActionEvent ae) {
System.err.println("submit");
}
}
main.xhtml
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<head>
<title>Test</title>
<ice:outputStyle href="xmlhttp/css/rime/rime.css" />
</head>
<body>
<ice:form partialSubmit="false" id="Form">
<ice:panelGrid columns="3">
<ice:inputText value="#{bean.text}" id="Text" required="true">
<f:validateLength minimum="2" />
</ice:inputText>
<ice:selectInputDate value="#{bean.date}" renderAsPopup="false" partialSubmit="false" id="Date" immediate="true" />
<ice:selectOneListbox value="#{bean.item}" size="1" required="true" id="Combo">
<f:selectItem itemLabel="Select..." itemValue="-1" />
<f:selectItem itemLabel="0" itemValue="0" />
<f:selectItem itemLabel="1" itemValue="1" />
<f:selectItem itemLabel="2" itemValue="2" />
<f:validateLongRange minimum="0" />
</ice:selectOneListbox>
</ice:panelGrid>
<ice:commandButton actionListener="#{bean.submit}" value="Submit" />
<br />
<ice:outputText value="Text: #{bean.text}<br/>Date: #{bean.date}<br/>Item: #{bean.item}" escape="false" />
</ice:form>
<ice:messages />
</body>
</html>
Bean.java
package org.local.test;
import java.util.Date;
import javax.faces.event.ActionEvent;
public class Bean {
private String text;
private Date date;
private Integer item;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Integer getItem() {
return item;
}
public void setItem(Integer item) {
this.item = item;
}
public void submit(ActionEvent ae) {
System.err.println("submit");
}
}
The issue is caused by the removal of every other child component of the selectInputDate component. This is happening in the encodeEnd method in the following lines:
// purge child components as they have been encoded no need to keep them around
selectInputDate.getChildren().removeAll(selectInputDate.getChildren());
This fails to remove all the children as it was probably intended. It goes in UIComponentBase's method:
public boolean removeAll(Collection<?> collection) {
{ result = true; }boolean result = false;
Iterator<?> elements = collection.iterator();
while (elements.hasNext()) {
if (remove(elements.next()))
}
return (result);
}
and removes every other child component.
Fixing this by calling selectInputDate.getChildren().clear(); generalizes the problem to all children including the even dates and "Show next month" or "Show next year" buttons.
The proper fix is to leave the child components in place because they are used later by the decode method that goes through all facets and children in order to queue the needed events.