Thanks Simon and Matthijs for your detailed replies and the next questions will go user list with [digester] in head of subject :).
Finnaly addSetRoot allowed me to addObject imediatelly after pushing the Factory instance on stack.
What happens now is that when </b> is reached, the stack is poped (top BBean obj) and after, the processB is called with whatever is on top of stack (ABean). And here I get the error.
I must implement some mechanism to keep a copy of the top BBean past the </b> tag.


Anyway, I now I think I understood the problem, which counts as 90% of the sollution.

Thanks again,

--mihai

----- Original Message ----- From: "simon" <[EMAIL PROTECTED]>
To: "Jakarta Commons Developers List" <[EMAIL PROTECTED]>
Sent: Monday, December 06, 2004 5:07 PM
Subject: Re: digester newbie question



On Mon, 2004-12-06 at 23:36, simon wrote:
> Digester d = new Digester();
> d.push(this); //stack bottom
> d.addSetNext( "root/a/b", "processB" , "BBean"); // when
> root/a/b pattern mathes, execute processB on 'this' with BBean type > param
> d.addSetNext( "root/a", "processA", "ABean"); // when > root/a
> pattern mathes, execute processA on 'this' with ABean type param
> d.addObjectCreate( "root/a", ABean.class);
> d.addObjectCreate( "root/a/b", BBean.class);
>
> I get this error:
>
> [DEBUG] Digester - -[SetNextRule]{root/a/b} Call
> Factory.processB([EMAIL PROTECTED])
> [ERROR] Digester - -End event threw exception
> <java.lang.IllegalArgumentException: argument type
> mismatch>java.lang.IllegalArgumentException: argument type mismatch
>




> Obviously, processB() was called with the wrong arg type(ABean instead > of
> BBean) and that because the BBean obj was just poped from the stack.


No, I think what is happening is that Digester is attempting to call a
method
   processB(BBean)
on an object of type ABean. The ABean class presumably doesn't have such
a method.

On re-reading the exception trace, I see I didn't look carefully enough the first time.

I still stand by my original comments, but the reason you are getting
this message:
[DEBUG] Digester - -[SetNextRule]{root/a/b} Call
Factory.processB([EMAIL PROTECTED])
is because you called d.addSetNext("root/a/b", ...) before you called
d.addObjectCreate("root/a/b", ...). This means that when the <b> element
is found, an attempt is made to call processB (passing the top object on
the stack) before the BBean object has been created and pushed on the
stack.

If you ensure the rules creating the ABean and BBean objects are added
before the rules that call processA/processB, then you will get a
*different* problem (being the one I described in my earlier email) but
I think this will at least be a step forward...

You may find it useful to download the "source" distribution of
digester-1.6 and look in the src/examples directory to see some simple
examples of how to use the commons digester.

And in future, please direct this sort of question to the "user" list
rather than the developer list. Almost all jakarta developers are also
watching the user list, so you lose nothing by asking on the correct
list. In addition there are many experienced coders on the user list who
could help, but are not subscribed to the dev list.

Cheers,

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to