I think the addition of pluggable converters in ConvertUtils on 3/18 has
changed the way Struts handles empty form fields that map to primitive
Wrapper bean properties. The default IntegerConverter uses a default value
of Integer(0) instead of null.
This is a fairly significant problem because it's not backwards compatible
with Struts 1.0. I often store id#s in hidden form fields that map to a Long
or Integer property on the serverside bean. If the hidden field is empty ""
in the html then Struts used to populate the setBlah(Integer) method with a
null, now it passes a zero. That causes me to try an update of entity 0
instead of adding a new entity, for example.
I modified the struts-exercise-taglib to add a test to demonstrate this
problem. Below are the patches to the two files that would need to be
changed.
-- add to struts-exercise-taglib html-setters.jsp
<tr>
<th align="right">integerProperty</th>
<td align="left">
<html:text property="integerProperty" size="32"/>
</td>
<th align="right">nested.integerProperty</th>
<td align="left">
<html:text property="nested.integerProperty" size="32"/>
</td>
</tr>
-- add to TestBean in .../webapp/exercise
/**
* An integer property.
*/
private Integer integerProperty = new Integer(123);
public Integer getIntegerProperty() {
return (this.integerProperty);
}
public void setIntegerProperty(Integer integerProperty) {
this.integerProperty = integerProperty;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>