commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <skitch...@apache.org>
Subject Re: Digester: Problem with CallMethodRule
Date Mon, 05 Sep 2005 07:25:14 GMT
On Mon, 2005-09-05 at 07:18 +0300, Mikko Nylén wrote:
> Hi!,
> 
> I'm having a little problem with Digester's CallMethodRule: it doesn't 
> call the method.
> 
> The XML file I try to parse is:
> 
> ---
> <configuration>
>   <pages>
>     <page path="/index.htm" class="test.TestPage" />
>     <page path="/hello.htm" class="test.HelloPage" />
>   </pages>
> </configuration>
> ---
> 
> The Java code I'm trying to use for parsing the configuration:
> 
> ---
> ...
> Digester digester = new Digester();
> digester.addObjectCreate("configuration", "test.Configuration");
> digester.addObjectCreate("configuration/pages/page", 
> "test.PageConfiguration");
> digester.addSetProperties("configuration/pages/page", new 
> String[]{"path", "class"}, new String[]{"path", "className"});
> digester.addCallMethod("configuration/pages/page", "freeze");
> digester.addSetNext("configuration/pages/page", "addPageConfiguration", 
> "test.PageConfiguration");
> 
> Configuration configuration = (Configuration)digester.parse(reader);
> ---
> 
> The problem is that the freeze() method of instantiated 
> PageConfiguration objects isn't ever called (which results to that the 
> Configuration's addPageConfiguration(PageConfiguration) throws an 
> IllegalStateException). How I should fix this? I'm using the version 1.7 
> of Digester.

Are you sure the problem isn't the *order* that methods get called for
element "configuration/pages/page" rather than that the freeze method
doesn't get called at all? 

I suggest reading the FAQ entry titled "How do I get CallMethodRule to
fire before SetNextRule?" here:
  http://wiki.apache.org/jakarta-commons/Digester/FAQ

Regards,

Simon



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