BTemplate is not fully compatible with XMLC philosophy
Thorsten Möller <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <01a901c3934b$0f6ae5c0$96e102d9@Thoro> |
@Barracuda developers:
There is a realy strange problem with the BTemplate component. Suppose you
have a html like this:
<html>
...
<body>
<span id="btemplate">
[some content with directives]
<p id="xmlc">my text</p>
</span>
</body>
</html>
And your code looks like this:
...
BTemplate templateComp = new BTemplate();
templateComp.addModel(new MyModel());
templateComp.addView(new DefaultTemplateView(page.getElementBtemplate()));
templateComp.initCycle();
try
{
templateComp.render(new DefaultViewContext(context));
}
catch (RenderException e) {}
templateComp.destroyCycle();
page.setTextXmlc("my new text");
...
When executing this code the text inside the <p> element with id "xmlc" will
not get replaced! Please don't ask why I want to do this, just take it for
granted.
It seems that the BTemplate component clones the node to which it is bound
to and then replaces the "old" node (I'm not sure but I think so). Setting
the text inside the <p> element before rendering the BTemplate will work.
But I don't want to be limited to do DOM manipulations via XMLC at first!
Another problem arises if you call "page.getElementXmlc()" after rendering
of BTemplate because you will get the "old" node which doesn't reflect the
new document.
If I'm right, please, please, please change the the way BTemplate renders
itself to not cloning the node.
Thorsten