commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wendy Smoak" <j...@wendysmoak.com>
Subject Re: [digester] Populating a LazyDynaBean with Digester
Date Wed, 19 Jan 2005 05:45:30 GMT
From: "Hubert Rabago" <hrabago@gmail.com>
> 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
    <download>
       <person key="0452360">
          <preferredName>Ms. Amy N. Smith</preferredName>
          <degree key="352">BS Computer Science</degree>
          <degree key="253">MBA Business Administration</degree>
       </person>
    </download>

 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?

Thanks,
-- 
Wendy Smoak 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message