https://facelets.dev.java.net/issues/show_bug.cgi?id=357 Issue #|357
Summary|When using ui:repeat and inputText with attributes tha
|t are 'nullable' (for example date attributes) they ca
|nnot be set to null by entering an empty String ("")
Component|facelets
Version|UNKNOWN
Platform|All
OS/Version|All
URL|
Status|NEW
Status whiteboard|
Keywords|
Resolution|
Issue type|DEFECT
Priority|P3
Subcomponent|impl
Assigned to|issues@facelets
Reported by|marcelurbanek
------- Additional comments from
marcelurbanek@... Fri Oct 2 22:32:56 +0000 2009 -------
(Affected Facelets Version is 1.1.15.B1)
When using ui:repeat in conjunction with an input field and a attribute with a
type that can normally be set to null by a user (for example a date) by entering
an empty string into the input field (""), it is not possible for the user to do
so. A small example:
TestBean.java:
public class TestBean {
public List testEntries=new LinkedList();
public TestBean(){
testEntries.add(new TestEntry());
}
public class TestEntry implements Serializable{
private Date testAttribute;
public Date getTestAttribute() {
return testAttribute;
}
public void setTestAttribute(Date testAttribute) {
System.out.println("set:"+testAttribute);
this.testAttribute = testAttribute;
}
}
public List getEntries(){
return testEntries;
}
}
test.xhtml (excerpt):
<ui:repeat value="#{TestBean.entries}" var="entry">
<h:inputText value="#{entry.testAttribute}">
<f:convertDateTime type="date" dateStyle="medium"/>
</h:inputText>
</ui:repeat>
When you now enter a Date (lets say 1/1/2009) it is accepted and set. If you try
to set the date to null by entering an empty string into the input field, it
gets set to its initial value (1/1/2009).
The problem happens in the "populate" method of UIRepeat.SavedState . It uses
"getValue" to get the current component value after the value was already set to
null. The "getValue" method itself will then try to get a value from the value
it is bind to instead, which is, at that state, still filled with the old data
(1/1/2009) and returns this value. When the "apply" Method is fired afterwards
the old value is then written again to the component value and the value binding
won't get updated with the null value. Using "getLocalValue" instead of
"getValue" seems to solve the problem:
public void populate(EditableValueHolder evh) {
this.value = evh.getLocalValue();
this.valid = evh.isValid();
this.submittedValue = evh.getSubmittedValue();
this.localValueSet = evh.isLocalValueSet();
}
---------------------------------------------------------------------
To unsubscribe, e-mail:
issues-unsubscribe@...
For additional commands, e-mail:
issues-help@...