commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Volkmann, Mark" <>
Subject RE: [jelly] parent and child tags
Date Mon, 08 Mar 2004 19:28:29 GMT
> -----Original Message-----
> From: Daryl Stultz []
> Sent: Monday, March 08, 2004 1:18 PM
> To: Jakarta Commons Users List
> Subject: Re: [jelly] parent and child tags
> "Jakarta Commons Users List" <> writes:
> >The simplest way for a child tag object to obtain its parent 
> tag object is
> >  DynamicBeanTag parentTag = (DynamicBeanTag) getParent();
> >  Object parentBean = parentTag.getBean();
> >  // At this point a cast is necessary to do anything useful will
> >parentBean.
> This certainly works and I "discovered" this solution myself.

I like the way you worded that.  I "discovered" it too.  ;-)
This really needs to go into the documentation if it is in fact the best way
to do this.
> Can't say if
> it's the simplest or most elegant, though.
> >
> >Parent tag objects cannot, in their doTag method, locate 
> their child tag
> >objects and invoke methods on them to "pull" data up.  I'm 
> really hoping,
> >I'm wrong about this.
> If you have the children can push themselves to the parent during
> invokeBody(...), then the parent can process them after the call to
> invokeBody(...), no?
> // parent code:
> 	public void doTag(XMLOutput output) throws Exception {
> 		invokeBody(output); // children push themselves up...
> 		processChildren(); // iterate over children 
> doing whatever
> 	}

Yes, that would certainly work.  I'm just thinking that if I have an element
with 20 different child elements, I don't want to create a class for each of
the child elements and have to tell each one to pass its data up to the
parent.  I guess what I really want is a way to treat child elements like
attributes are treated ... set methods are automatically called.  For
example, I want


to result in creation of a foo object and the call foo.setBar(7).

A.G. Edwards & Sons' outgoing and incoming e-mails are electronically
archived and subject to review and/or disclosure to someone other 
than the recipient.


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