commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wendy Smoak" <>
Subject Re: [digester] Populating a LazyDynaBean with Digester
Date Wed, 19 Jan 2005 05:45:30 GMT
From: "Hubert Rabago" <>
> Not an answer to the question you were asking, but looking at your
> code, I thought I'd share that
>>          digester.addObjectCreate("download", LazyDynaBean.class);
>>          digester.addSetNestedProperties("download/person");
>   works, and adds a preferredName property (and value) to your 
> lazydynabean.
> Of course, given your case (where you also indexed props at
> download/person/degree), I'm not sure if your overall result would be
> what you want.

Thanks for the tip-- it does work, but it's a little overzealous.  Out of 
this example xml
       <person key="0452360">
          <preferredName>Ms. Amy N. Smith</preferredName>
          <degree key="352">BS Computer Science</degree>
          <degree key="253">MBA Business Administration</degree>

 I end up with a 'degree' property set as well as my 'degrees' mapped [was 
indexed] property that I handle separately with
         digester.addCallMethod("download/person/degree", "set", 3);
         digester.addObjectParam("download/person/degree", 0, "degrees");
         digester.addCallParam("download/person/degree", 1, "key");
         digester.addCallParam("download/person/degree", 2);

Not _quite_ there yet.  This wasn't a problem when I was populating my own 
javabean, I simply told SetNestedProperties to allowUnknownChildElements, 
and since there _was_ no 'setDegree()' method, nothing bad happened.  Not so 
here, it invents properties I didn't intend.

I need to specify what properties my dynabean has up front and not let new 
ones be created... obviously I need something other than LazyDynaBean, maybe 
BasicDynaClass would work better for this?

Wendy Smoak 

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message