Uh... nevermind.  I think I just found the answer.  

The Subscription object is passed a reference to the "parent" object via
it's setUser method and it calls the parent's addSubscription method to add
itself.

I'll just throw this out there: It would seem to me that it would make more
sense for the Digester to add the child object directly to the parent by
calling the parent's add method.  Of course, this would mean that the
digester would have to know what the parent is in relation to the child
(perhaps it already does? I don't know).  I just think it's better than
forcing the implementation of an additional method in the child to add
itself to the parent.  That way, you could more freely define what child
object to use (especially if you have one that already exists) and just
implement a method in the parent.  

Perhaps it's not too big of a deal?  Any thoughts?

Thanks :)

Scott


-----Original Message-----
From: Sayles, Scott SAXONHQ 
Sent: Thursday, November 02, 2000 9:55 AM
To: '[EMAIL PROTECTED]'
Subject: struts-example question - DatabaseServlet / Digester


I'm just looking for a clarification of how digester.addSetTop works in the
example.

>From DatabaseServlet.load() 
...................................................
        digester.addObjectCreate("database/user",
                                 "org.apache.struts.example.User");
        digester.addSetProperties("database/user");
        digester.addSetNext("database/user", "addUser");
        digester.addObjectCreate("database/user/subscription",
                                 "org.apache.struts.example.Subscription");
        digester.addSetProperties("database/user/subscription");
        digester.addSetTop("database/user/subscription", "setUser");
....................................................

>From what I can gather, the addSetTop method adds a SetTopRule which
specifies that the Subscription object will be added to the parent object,
User, via the setUser method.  Am I understanding this correctly?  If I am,
then where is the setUser method?  Shouldn't "setUser" be "addSubscription"?

Thanks :)

Scott

Reply via email to