commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shvets, Steve" <sshv...@ubspw.com>
Subject RE: [digester] Is there a way to populate bean using XML rules in one statement
Date Thu, 24 Apr 2003 18:07:43 GMT
thank you very much...

-----Original Message-----
From: robert burrell donkin
[mailto:robertburrelldonkin@blueyonder.co.uk]
Sent: Thursday, April 24, 2003 1:31 PM
To: Jakarta Commons Users List
Subject: Re: [digester] Is there a way to populate bean using XML rules
in one statement


in that case, kevin's right that all you need to do is use a 
BeanPropertySetterRule with a pattern that includes all the element's your 
interested in.

for example, use the ExtendedBaseRules

digester.setRules(new ExtendedBaseRules());

...

digester.addBeanPropertySetter("account/?")

(this should make a standard BeanPropertySetterRule match all child 
elements of accounts.)

- robert

On Thursday, April 24, 2003, at 05:34 PM, Shvets, Steve wrote:

> Robert,
>
> here is an example
>
> <account>
> 	<name>steve</name>
> 	<balance>1000.00</balance>
> </account>
>
> I have a bean
>
> class Bean {
> 	private String name = null;
> 	private String balance=null;
> 	public String getName()
> 	{
> 		return name;
> 	}
> 	public void setName(String name)
> 	{
> 		this.name=name;
> 	}
> 	....
> }
>
> How can I set properties of this bean with one xml rule?
> I thought BeanPropertySetterRule is for that purpose...What would be an 
> xml
> rule syntax?
>
> thank you Steve
>
> -----Original Message-----
> From: robert burrell donkin
> [mailto:robertburrelldonkin@blueyonder.co.uk]
> Sent: Thursday, April 24, 2003 12:14 PM
> To: Jakarta Commons Users List
> Subject: Re: [digester] Is there a way to populate bean using XML rules
> in one statement
>
>
> i'm not really sure i understand how you want to populate a bean's
> properties from the body text of one element.
>
> i can see populating from the body text of elements (each mapping to one
> property) eg.
>
> <bean><propertyOne>Value One</propertyOne><propertyTwo>Value
> Two</propertyTwo></bean>
>
> but if you're parsing the body text to establish the values for the
> properties eg.
> <bean>Value One,Value Two</bean>
>
> then this is going to require parsing of the body text. if this is what
> you need to do, then a custom rule (containing the parsing code) is
> probably the best way to approach this problem.
>
> - robert
>
> On Thursday, April 24, 2003, at 05:02 PM, Shvets, Steve wrote:
>
>> I was just hoping to
>> populate all the properties on a bean from an
>> element's text...I thought BeanPropertySetterRule is for that 
>> purpose...Is
>> there an alternative xml rule
>>
>> thank you so much for replying
>> I will look into betwixt too...
>>
>> -----Original Message-----
>> From: robert burrell donkin
>> [mailto:robertburrelldonkin@blueyonder.co.uk]
>> Sent: Thursday, April 24, 2003 11:56 AM
>> To: Jakarta Commons Users List
>> Subject: Re: [digester] Is there a way to populate bean using XML rules
>> in one statement
>>
>>
>> hi steve
>>
>> this all depends on how your mapping works :)
>>
>> SetPropertiesRule will populate all the properties on a bean from an
>> element's attributes. if you want anything more complex, then you may 
>> want
>> to take a look at betwixt which builds on digester but specializes in
>> automated bean<->xml mapping.
>>
>> - robert
>>
>> On Thursday, April 24, 2003, at 03:37 PM, Shvets, Steve wrote:
>>
>>> Hi,
>>>
>>> I was just wondering is there a way to populate a Bean with one XML rule
>>>
>>> I guess I am looking for XML BeanPropertySetterRule
>>>
>>> Can anyone give me an example....
>>>
>>> Any help is greatly appreciated...
>>>
>>> Thank you Steve
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
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