You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Raymond Lukas <rl...@cadence.com> on 2003/02/21 17:28:14 UTC

Trigger method call on an end Tag

Please if someone could give me a hand. How do I trigger a method call
when I hit the </Tag>.. In the small example below I am looking to nest
List elements in a document generation system. If I could just detect
and trigger a method call on the </List> I would be all set. I read the
manual but it did not help me out enough. An example on the other hand
would be GREAT!! This is an important project and I really need someone
to take a few minutes and post an example or a pointer to an example... 

 

 

 

I need to handle nesting element inside of my XML file.. Something like
this:

      <HeaderLevel1 headerName = "Diva DRC">

            <List type = "numbered">

                  <Entry name="OutterA">                      

                        <List type = "dotted">                    

                              <Entry name=" InnerA ">

                              </Entry>

                              <Entry name=" InnerB ">

                              </Entry>

                        </List>

                  </Entry>                

                  <Entry name="Outter">                       

                        <List type = "dotted">                    

                              <Entry name="InnerA">

                              </Entry>

                              <Entry name="InnerB">

                              </Entry>

 

                        </List>

                  </Entry>                                  

            </List>

      </HeaderLevel1>

      

 

Inside of my Digest setup I have something like this. Well exactly like
this. Everything is call fine, I just need to know when I am at the end
of each List Element.. 

 

        Class listClass = ListElement.class;

        digester.addObjectCreate("*/List", listClass);

        digester.addSetProperties("*/List"); 

        //digester.addCallMethod("Section/HeaderLevel1/List/Entry",
"addInnerListEntry");                         

 

        //      --------------------------------------

         Class entryClass = Entry.class;

         digester.addObjectCreate("*/List/Entry", entryClass);

         digester.addSetProperties("*/List/Entry"); 

         digester.addSetNext("*/List/Entry", "addEntry");  


[digester] Re: Trigger method call on an end Tag

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi Raymond

please remember to add a prefix containing the component.

i'd say that the easiest way to do this quickly is for you to create a new 
Rule subclass which overrides the Rule implementation of end(String, 
String, String) to make your method call.

for example, something like (untested psuado-code)

digester.addRule("*/List", new Rule {
					public end(String namespace, String name) {
							// make that method call!
							...
						}
				})

hope this helps.

- robert

On Friday, February 21, 2003, at 04:28 PM, Raymond Lukas wrote:

> Please if someone could give me a hand. How do I trigger a method call
> when I hit the </Tag>.. In the small example below I am looking to nest
> List elements in a document generation system. If I could just detect
> and trigger a method call on the </List> I would be all set. I read the
> manual but it did not help me out enough. An example on the other hand
> would be GREAT!! This is an important project and I really need someone
> to take a few minutes and post an example or a pointer to an example...
>
>
>
>
>
>
>
> I need to handle nesting element inside of my XML file.. Something like
> this:
>
>       <HeaderLevel1 headerName = "Diva DRC">
>
>             <List type = "numbered">
>
>                   <Entry name="OutterA">
>
>                         <List type = "dotted">
>
>                               <Entry name=" InnerA ">
>
>                               </Entry>
>
>                               <Entry name=" InnerB ">
>
>                               </Entry>
>
>                         </List>
>
>                   </Entry>
>
>                   <Entry name="Outter">
>
>                         <List type = "dotted">
>
>                               <Entry name="InnerA">
>
>                               </Entry>
>
>                               <Entry name="InnerB">
>
>                               </Entry>
>
>
>
>                         </List>
>
>                   </Entry>
>
>             </List>
>
>       </HeaderLevel1>
>
>
>
>
>
> Inside of my Digest setup I have something like this. Well exactly like
> this. Everything is call fine, I just need to know when I am at the end
> of each List Element..
>
>
>
>         Class listClass = ListElement.class;
>
>         digester.addObjectCreate("*/List", listClass);
>
>         digester.addSetProperties("*/List");
>
>         //digester.addCallMethod("Section/HeaderLevel1/List/Entry",
> "addInnerListEntry");
>
>
>
>         //      --------------------------------------
>
>          Class entryClass = Entry.class;
>
>          digester.addObjectCreate("*/List/Entry", entryClass);
>
>          digester.addSetProperties("*/List/Entry");
>
>          digester.addSetNext("*/List/Entry", "addEntry");
>