Hello Thomas, I created TRB-93 for this issue. Because I couldn't attach the patch file to the jia, I attached patch by cut and paste. But the view is not clear so attach the patch file again here.
Thanks, Youngho 2014-11-05 18:53 GMT+09:00 Youngho Cho <youngho1...@gmail.com>: > Hello Thomas, > > I read trunk Field.java and old Field.java which I use, > > And find out that some days ago 'getSafeEmptyValue()' method introduced. > But because the history log is missing at the apache svn, I don't know > why this code introduced and what for. > > Anyway because of this method, the calling setter force the value set > to 0 of number even the parameter parser has not the field value. > > And I think this behavior conflicts with the Field.java setProperty() > method document. > the document says that "Calls a setter method on obj, if this field > has been set." > > Because that change happened a long times ago, and I can't find any > issue about this behavior at the issue tracker > I think intake user use without any problem but how? > > Is there any way to keep 'null' state at the current code by setting > or > Do I have to create a bug ticket about this behavior > or > Do I use my own numberField by extending intake numberField ? > > > Thanks, > > Youngho > > > > > 2014-11-04 10:22 GMT+09:00 Youngho Cho <youngho1...@gmail.com>: >> Hello Thomas, >> >> Here is the diff which I tested with trunk intake. >> >> I an not sure how can I keep the 'null' state. >> >> >> Thanks, >> >> Youngho >> >> //********************************************* >> >> Index: src/java/org/apache/fulcrum/intake/model/Field.java >> =================================================================== >> --- src/java/org/apache/fulcrum/intake/model/Field.java (revision 1629357) >> +++ src/java/org/apache/fulcrum/intake/model/Field.java (working copy) >> @@ -42,7 +42,7 @@ >> * Base class for Intake generated input processing classes. >> * >> * @author <a href="mailto:jmcna...@collab.net">John McNally</a> >> - * @author <a href="mailto:d...@finemaltcoding.com>Daniel Rall</a> >> + * @author <a href="mailto:d...@finemaltcoding.com">Daniel Rall</a> >> * @author <a href="mailto:h...@intermeta.de">Henning P. Schmiedehausen</a> >> * @author <a href="mailto:quint...@bellsouth.net">Quinton McCombs</a> >> * @author <a href="mailto:j...@byteaction.de">Jürgen Hoffmann</a> >> Index: src/test/intake1.xml >> =================================================================== >> --- src/test/intake1.xml (revision 1629357) >> +++ src/test/intake1.xml (working copy) >> @@ -56,4 +56,20 @@ >> <rule name="invalidNumber">Not a number</rule> >> </field> >> </group> >> + >> +<group name="AttributeValue" key="attv" mapToObject="AttributeValue"> >> + <field name="Id" key="id" type="long" mapToProperty="ValueId"> >> + <rule name="mask" value="[0-9]+">intakeBadIdMessage</rule> >> + <rule name="required" value="false"></rule> >> + </field> >> + <field name="AttributeId" key="attid" type="int"> >> + <rule name="mask" value="[0-9]+"></rule> >> + <rule name="required" value="true">Required</rule> >> + </field> >> + <field name="UserId" key="visid" type="int"> >> + <rule name="mask" value="[0-9]+">intakeBadIdMessage</rule> >> + <rule name="required" value="false"></rule> >> + </field> >> +</group> >> + >> </input-data> >> Index: src/test/org/apache/fulcrum/intake/IntakeTest.java >> =================================================================== >> --- src/test/org/apache/fulcrum/intake/IntakeTest.java (revision 1629357) >> +++ src/test/org/apache/fulcrum/intake/IntakeTest.java (working copy) >> @@ -23,6 +23,7 @@ >> >> import org.apache.fulcrum.intake.model.Field; >> import org.apache.fulcrum.intake.model.Group; >> +import org.apache.fulcrum.intake.test.AttributeValue; >> import org.apache.fulcrum.intake.test.LoginForm; >> import org.apache.fulcrum.intake.validator.BooleanValidator; >> import org.apache.fulcrum.intake.validator.IntegerValidator; >> @@ -255,4 +256,36 @@ >> assertEquals("Invalid number message is wrong.", "Not a >> number", ve.getMessage()); >> } >> } >> + >> + public void testEmptyNumberField() throws Exception >> + { >> + IntakeService is = (IntakeService) this.resolve( >> IntakeService.class.getName() ); >> + Group group = is.getGroup("AttributeValue"); >> + assertNotNull(group); >> + >> + ParserService ps = (ParserService) this.resolve( >> ParserService.class.getName() ); >> + ValueParser pp = ps.getParser(DefaultParameterParser.class); >> + >> + pp.add("attv_0attid", "1"); >> + group.init(pp); >> + >> + Field<?> attributeField = group.get("AttributeId"); >> + assertNotNull(attributeField); >> + assertEquals(1, attributeField.getValue()); >> + >> + Field<?> valueField = group.get("Id"); >> + assertNull(valueField.getValue()); >> + >> + Field<?> userField = group.get("UserId"); >> + assertNull(userField.getValue()); >> + >> + AttributeValue value = new AttributeValue(); >> + assertTrue(group.isAllValid()); >> + // >> + group.setProperties(value); >> + >> + assertEquals(Integer.valueOf(1), value.getAttributeId()); >> + assertNull(value.toString(), value.getValueId()); >> + assertNull(value.toString(), value.getUserId()); >> + } >> } >> Index: src/test/org/apache/fulcrum/intake/test/AttributeValue.java >> =================================================================== >> --- src/test/org/apache/fulcrum/intake/test/AttributeValue.java (revision >> 0) >> +++ src/test/org/apache/fulcrum/intake/test/AttributeValue.java >> (working copy) >> @@ -0,0 +1,75 @@ >> +package org.apache.fulcrum.intake.test; >> + >> + >> +public class AttributeValue { >> + >> + private Long valueId; >> + >> + private Integer attributeId; >> + >> + private Integer userId; >> + >> + /** >> + * @return >> + */ >> + public Long getValueId() { >> + return valueId; >> + } >> + >> + /** >> + * @param userId >> + */ >> + public void setValueId(Long valueId) { >> + this.valueId = valueId; >> + } >> + >> + /** >> + * @return >> + */ >> + public Integer getAttributeId() { >> + return attributeId; >> + } >> + >> + /** >> + * @param attributeId >> + */ >> + public void setAttributeId(Integer attributeId) { >> + this.attributeId = attributeId; >> + } >> + >> + /** >> + * @return >> + */ >> + public Integer getUserId() { >> + return userId; >> + } >> + >> + /** >> + * @param userId >> + */ >> + public void setUserId(Integer userId) { >> + this.userId = userId; >> + } >> + >> + //**************************************** >> + // primitive for intake >> + public void setValueId(long valueId) { >> + setValueId(Long.valueOf(valueId)); >> + } >> + public void setAttributeId(int attributeId) { >> + setAttributeId(Integer.valueOf(attributeId)); >> + } >> + public void setUserId(int userId) { >> + setUserId(Integer.valueOf(userId)); >> + } >> + public String toString() { >> + final StringBuilder sb = new StringBuilder(); >> + sb.append("ValueId "); >> + sb.append(this.valueId); >> + sb.append(", AttributeId "); >> + sb.append(this.attributeId); >> + sb.append(", UserId "); >> + sb.append(this.userId); >> + return sb.toString(); >> + } >> +} >> >> >> 2014-11-03 1:35 GMT+09:00 Thomas Vandahl <t...@apache.org>: >>> On 31.10.14 04:26, Youngho Cho wrote: >>>> Hello, >>>> >>>> I am migrating very old intake to current trunk version. >>>> >>>> I have a question about usage for 'null' number state. >>>> >>>> for example, >>>> >>>> I would like to keep 'null' state when input parameter doesn't have a >>>> value for number field. >>>> >>>> But >>>> >>>> during the group.setProperties(OM) process >>>> the empty field value set to '0' value of number. >>>> >>>> How can I keep 'null' state ? >>> >>> Could you please show me the relevant part of your intake.xml? >>> >>> Bye, Thomas. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscr...@turbine.apache.org >>> For additional commands, e-mail: dev-h...@turbine.apache.org >>>
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@turbine.apache.org For additional commands, e-mail: dev-h...@turbine.apache.org