commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Kaiser" <Carsten.Kai...@valtech.de>
Subject AW: Problems with digester
Date Wed, 10 Mar 2004 12:41:29 GMT
Hello Diego,
 
you can use a call method rule instead e.g. like this:
digester.addCallMethodRule("class/property/meta", "setData", 0, "java.lang.String");
Paramcount = 0 will call the setData method on your Meta-Object using the body of your meta
tag...
 
Hope this works... ;-)
 
Bye,
CK

	-----Urspr√ľngliche Nachricht----- 
	Von: Diego [mailto:diego.manilla@xeridia.com] 
	Gesendet: Mi 10.03.2004 13:32 
	An: commons-user@jakarta.apache.org 
	Cc: 
	Betreff: Problems with digester
	
	

	Hi everyone!
	
	I'm using commons digester to parse a xml file like this:
	
	<class>
	    <property>
	        <meta attribute="field-description">data1</meta>
	        <meta attribute="field-description">data2</meta>
	    </property>
	</class>
	
	I'm having problems getting the body of "meta" tags. I just get "null".
	
	                digester.addObjectCreate(
	                        "class/property/meta",
	                        Meta.class);
	                digester.addSetProperties(
	                        "class/property/meta",
	                        "attribute",
	                        "type");
	                digester.addBeanPropertySetter(
	                        "class/property/meta",
	                        "data");
	                digester.addSetNext(
	                        "class/property/meta",
	                        "addMeta");
	
	In the Meta class I have defined two String fields, "data" and "type", with
	their respective getters and setters. The addMeta method is correctly defined
	in
	the Property class, but when I set a breakpoint in this method, the Meta object
	comes with the "data" field set to null. The "type" is parsed correctly.
	
	I think the problem is in this statement:
	
	                digester.addBeanPropertySetter(
	                        "class/property/meta",
	                        "data");
	
	In all the digester examples I've seen, the addBeanPropertySetter is used to
	pick the body of tags nested into the "object tag", and not the object tag
	itself.
	
	What am I doing wrong?
	
	thanks in advance
	
	----------------------------------------------------------------
	This message was sent using IMP, the Internet Messaging Program.
	
	
	---------------------------------------------------------------------
	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