Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] Listeners

Daniel Perry

2004-07-06

Replies:

I've been searching through the mailing lists for info on adding Listeners
to monitor changes in documents, etc.

So far i've figureed out that these listeners dont exist, and every
proposal/idea that i've come accross in the lists are concerned with events
at the element level.

I am trying to work out how to do it at the document level.

I'm using jdom to work with config files and data files. In a current
project i need to save these files when they are changed. I would rather
somthing at a core level does this through a listener rather than call a
method after changing anything.

ie at the moment i am doing:

_someElement.setText("newValue");
// somehow get a reference to an xmlHandler class that is responsible for
this document, then...
xmlHandler.save();

I would rather do:

_someElement.setText("newValue");

and have the Document the element belongs to fire off an event through a
listener.

Does anyone have any suggestions on how i can do this?

As far as i can see, i would have to extend element and add a reference to
it's document. I would have to also override any methods that change
content to fire off an event through the document. I would have to extend
document to add the listener methods. I would then have extend saxbuilder
and make it use these new types.

Is there an easier way to do this?

Thanks,

Daniel.

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.