[jdom-interest] setContent NOT setting parent correctly.
Bradley S. Huffman
hip at cs.okstate.edu
Thu Oct 16 12:00:21 PDT 2003
"Dave Bartmess" writes:
> Actually, it's not. The FAQ covers how to copy/move a single element,
> but not the entire contents of an element. I don't want to clone the
> element, I want to copy the contents of element A to element B,
> replacing the existing contents in element B.
element1.setContent( element2.removeContent()); should do that (but the no arg
removeContent() is only in the latest cvs), if it doesn't then that's a bug
that needs to be fixed.
> The problem is, I have over 70 classes which all need to be able to do
> this. setContent(Collection) is specifically supposed to 1) remove the
> existing contents of the element, detach the contents of the passed
> element's ContentList, and add the resulting set of detached children to
> the current element.
setContent was never suppose to automagically detach nodes already attached
to another parent. There have been discussions about whether add/setContent
should automagically detach nodes, but the general feeling is that this makes
it to easy for logic error to go unnoticed.
Brad
More information about the jdom-interest
mailing list