SmartGWT / GWT accessing div created in constructor via javascript
I am trying to integrate a custom javascript library with my SmartGWT
project.
I have areas of my page which are loaded dynamically via button clicks and
so in the Java code I have something like the following pseudo code:
button . onClick {
contextArea = new contextAreaTypeA()
}
So my contextAreaTypeA is created and within the constructor I want to
create a series of div elements, assign them IDs and then call a function
in my custom library which loads content into those divs.
SmartGWT gets rid of any way of getting hold of IDs or setting IDs on any
element in the page, to create IDs on elements you either have to create
your own widget and override getInnerHtml or create something like a
HTMLFlow and add content like myflow.setContent('<div id="myID" ></div>');
which is the way I am doing it.
My problem is that doing this in the constructor means that when I come to
call my custom javascript function which takes an ID, this div I created
does not seem to be attached to the dom yet so I always get a null
pointer.
Since my module and document are already loaded and this content is being
dynamically added in I can't call document ready or onModuleLoad, so how
and when should I be detecting the load of my div and when is it safe to
access the div from within JSNI calls?
I have tried multiple methods such as adding attach handlers (they never
seem to be called), I have tried adding draw handlers to the HTMLFlow but
they seem to be called after its drawn the htmlflow div but before it's
actually drawn the contents. I have tried calling redraw on the HTMLFlow()
but this doesn't even seem to call an onDraw method at all.
I have no idea how to go about integrating this library with my SmartGWT,
if anyone could suggest a better (or any) way of doing this that would be
great.
No comments:
Post a Comment