commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Burger...@rtin-burger.de>
Subject [Digester] Problems setting a bean property
Date Thu, 30 Jun 2005 06:47:39 GMT
Hello,

in a nutshell: after adding a method called "is<property name>" that 
returns a boolean value, Digester does not set the bean's property anymore.

I have the following simple XML file:

    <!DOCTYPE root>
    <values>
        <value>one</value>
        <value>two</value>
    </values>


I'm using Digester to set a field in a bean "Value":

    public class Value {

        private String value;

        public String getValue() {
            return this.value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }


Calling the code

    Digester digester = new Digester();

    digester.addObjectCreate("values/value", Value.class);
    digester.addSetNext("values/value", "add", "java.lang.Object");
    digester.addBeanPropertySetter("values/value", "value");

    List values = new ArrayList();
    digester.push(values);

    digester.parse(this.getClass().getResourceAsStream("data.xml"));

    Iterator iterator = values.iterator();
    while (iterator.hasNext()) {
        Value aValue = (Value) iterator.next();
        System.out.println(aValue.getValue());
    }


prints "one two" to the console.

If I add a method "isValue()" to the class Value

    public boolean isValue() {
        return this.value != null;
    }


"null null" is printed to the console.

So, after adding that method to the bean, Digester (or one of it's used 
components) does not call the method to set the field (setter) anymore.

Is this behavior intended, or is this a bug?

Regards,
    Martin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message