commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Egervari" <>
Subject [Digester] Parent Reference Help
Date Tue, 31 Aug 2004 00:01:02 GMT


Is there any way to reference a parent object when parsing an XML document
using the commons-digester component?  For example, let's assume that there
is an addObjectCreate() rule that creates a Page object for the <page> tag
and a SelectOne object for the <selectone> tag.  If I have the following XML
(shown below), is there any way the reference of my Page object can be
passed in the SelectOne object before the SelectOne's setters are called
using a typical addSetProperties() rule?  I'm having trouble obtaining a
reference since using addSetTop() is called after the setters are called.  


This is rather inconvenient since some setters (in SelectOne for instance)
will often need access to the parent object (the Page object in this
instance).  In other instances, I need to traverse up the graph of objects
to the root.  Since the parent is not defined, this is impossible.  


If I cannot access the parent as the setters are being called, I'm basically
forced to put this logic in the parent's addChild method instead where all
the attributes have been mapped to the object's properties already, but this
makes the object less convenient outside the digester.


<page index="2" formView="page.three.form">

      <selectone name="company.language" referenceData="languages"


            errorMessage="There are no languages in the database." />


I'm not flooding the message with source code because I don't think it's
required.  The specifics of the example are unimportant and I'm more
interested in a general solution.


Thanks for helping me out and best regards,


Ken Egervari




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message