Hello,
I just spent quite a bit of time debugging some code that uses a
Digester, and I'd like to share what I found.
class MyBean {
SomeType p = new SomeType();
public void setProp(SomeType p) {
this.p = p;
}
String name;
public void setName(String name) {
System.err.println("Setting name...");
this.name = name;
}
}
...
<mybean name="Fred"/>
...
digester.addSetProperties("mybean");
The name property was never being set..
The problem was that SomeType was not in my runtime CLASSPATH, so even
though setProp() is never called, and hence no runtime error occurs,
Digester fails to ever call setName(). Of course, the error here is
really mine, but I'd like to at least see Digester give some debugging
messages (I had debug detail set to 999).
2. Next I was trying to get the body of a tag and set a bean property
with the content:
<mybean name="Fred">Some content</mybean>
...
digester.addSetProperties("mybean");
digester.addCallMethod("mybean", "setBody", 0);
digester.addSetNext("mybean", "addMyBean");
I discovered that at the point addMyBean() is called, setBody() has not
been called yet. I realize that I'm just setting up a Digester
here (not actually doing the parsing), so I can imagine that the order of
events is not really defined here. However, it seems like the parsing
should generally follow the order that I set up the Digester in. Am I
missing something?
Anyway, I'll look at the struts source and see if I can come up with
suggestions or patches for struts-dev, but I thought I'd share this info
in case it helps anyone.
Zach