commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Sanders" <ssand...@nextance.com>
Subject RE: [DIGESTER] simple xml attribute to java attribute mapping?
Date Fri, 11 Jan 2002 00:23:28 GMT
Thought about that one as well,  was just *too* lazy to write one more
class :)

Thanks Craig, I will do that,
Scott

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org] 
> Sent: Thursday, January 10, 2002 4:22 PM
> To: Jakarta Commons Developers List
> Subject: Re: [DIGESTER] simple xml attribute to java 
> attribute mapping?
> 
> 
> On Thu, 10 Jan 2002, Scott Sanders wrote:
> 
> > Date: Thu, 10 Jan 2002 16:00:52 -0800
> > From: Scott Sanders <ssanders@nextance.com>
> > Reply-To: Jakarta Commons Developers List 
> > <commons-dev@jakarta.apache.org>
> > To: commons-dev@jakarta.apache.org
> > Subject: [DIGESTER]  simple xml attribute to java attribute mapping?
> >
> > What is the best way in digester to do a simple xml attr -> 
> java attr 
> > mapping.
> >
> > For example:
> >
> > <tag name="foo" style="bar"/>
> >
> > And the class looks like:
> >
> > Class Tag {
> >   public void setName(String name) {...}
> >   public void setStyleName(String style) {...}
> > }
> >
> > The SetPropertiesRule handles the name->setName() case, but what is 
> > the easiest way to handle the style->setStyleName() case?
> >
> > Silly question, but my brain is dead, I am currently using 
> > CallMethodRule with CallParamRule, and I think there should be a 
> > better way :)
> >
> 
> There aren't any current Digester rules that do that kind of 
> thing for you.  Presumably, you'd want to be able to map more 
> than one attribute-property pair.
> 
> A way to make this work would be to define a BeanInfo class 
> for your bean class that returned a PropertyDescriptor for 
> the 'style' property that says the setter method is really 
> 'setStyleName'.  This will get picked up by the introspection 
> mechanism in PropertyUtils (which is what Digester is using 
> underneath), with no changes to Digester.
> 
> > Scott
> >
> 
> Craig
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:commons-dev-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:commons-dev-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message