On 4/21/06, Valerio Schiavoni <[EMAIL PROTECTED]> wrote:
> Hello,
> i have the following xml:
> <root>
> <element id="A">
> <subelement id="B"/>
> </element>
> </root>
>
> whenever I match path element/subelement, i need to invoke a 2-parameters
> method defined on the object on the stack
> ,call it twoParamMethod(String idElement,String idSubElement).
>
> i was able to code up to this code:
>
> digester.addCallMethod("root/element/subelement", "twoParamMethod", 2);
> //HOW DO I GET THE VALUE FOR THE FIRST PARAMETER ?
<snip/>
Personally, I wouldn't use CallMethodRule here, but I rarely use it
anywhere. In this case, some options:
* Add a SetNextRule where you have access to both the "element" and
"subelement", and therefore, all params to call the method
* Add a custom rule that peeks one down the stack to find the
"element" (custom rules are not hard, ofcourse if you can do what you
need with "provided" rules, thats better most of the times)
-Rahul
> digester.addCallParam("root/element/subelement", 1, "id"); //value for the
> second parameter
>
> i need to this to fill in a map (stored in the root object) key="element
> id", values="list of id-s of subelements";
>
> thanks,
> valerio
>
> --
> http://valerioschiavoni.blogspot.com
> http://jroller.com/page/vschiavoni
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]