View Full Version : [CLOSED] Possible getElement bug

Colin Alworth
16 Jun 2009, 1:53 PM
It is entirely possible that I am using this wrong, but I have two usecases where this issue occurs...

Before an object is rendered, I need to add an additional DOM element to it. For various reasons, it makes more sense to do this manually than to extend the object and add to the onRender call.

LayoutContainer lc = new LayoutContainer();//Also tested with Field<?>
lc.getElement().appendChild(XDOM.create("<div>my content</div>"));

parent.add(lc);As lc.getElement() is called before it is rendered, the Component.dummy object is created, and returned. However, as far as I can tell, any content that I apply to that dummy never gets draw to the page.

From my quick reading of Component.onAttach(), it appears that the dummy is removed from its location, and the Component is drawn in its place. However, as far as I can tell, the contents of dummy are never attached in any way. Is this an invalid use of the prerender getElement() call? And if so, what is a valid use of getElement() before the element is rendered?

By way of clarification, my intent is to draw something extra to the element, like help text, but in such a way as to not interfere with the normal drawing code. Were the render complete, I would be able to use getElement() to do exactly this - this gets me around an extra event attachment - in Javascript these aren't a big deal, but in Java these make for rather ugly beasts - the first two lines of my example code need to be wrapped in three or four lines of callback creation and attachment code.


16 Jun 2009, 1:57 PM
You need to extend LayoutContainer and override the onRender method. You could also listen to the render event and add your addtional content in that event. There is no other way with the componenetmodel of GXT, as it uses lazy rendering.

I am closing this issue.

Colin Alworth
16 Jun 2009, 2:02 PM
Thanks for the quick reply - what is the purpose of the dummy element then?

16 Jun 2009, 2:08 PM
It is needed so that GXT components work with GWT widgets.