commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maher Martin <MMa...@Webasto.de>
Subject Digester Problem related to Bean Classname
Date Thu, 06 Feb 2003 15:20:58 GMT
Hi,

I've encountered a strange problem with Digester which is related to the
name of the java bean class. If I name the Java class "x.y.Component" then
the <set-properties-rule /> fails to call the setter methods for the bean
class. However if I rename the class to "x.y.Component2" all setters are
invoked by Digester when parsing the XML.

Can anybody explain what's going on here? I've included examples below.

Best Regards

Martin Maher

------ Component Class --------

package x.y

public class Component {

  private int _number;
  private String _type;

  public Component() {
  }

  public void setNumber(int number) {
    _number = number;
  }

  public void setType(String type) {
    _type = type;
  }

  public int getNumber() {
    return _number;
  }

  public String getType() {
    return _type;
  }

  public String toString() {
    String newline = System.getProperty("line.separator");
    StringBuffer sBuf = new StringBuffer();

    sBuf.append("Number:").append(_number).append(newline);
    sBuf.append("Type:").append(_type).append(newline);

    return sBuf.toString();
  }

}

------INPUT XML FILE--------

<?xml version="1.0"?>

<component number="1" type="a">
</component>

------ XML RULES --------

<?xml version="1.0"?>

<digester-rules>

	<pattern value="component">
		<object-create-rule classname="x.y.Component" />
		<set-properties-rule />
	</pattern>

</digester-rules>
--------------

Mime
View raw message