PDA

View Full Version : Threading with onRender



FollowSteph.com
18 Aug 2009, 9:13 AM
Hi,

I'm still learning GWT/GXT so this may be a more basic question.

Basically I have 3 classes. Class 1 is: public class DocumentTable extends LayoutContainer. Class 2 is basically the same but another name (FolderTable).

Now the 3rd class is my main class, with the method "public void onModuleLoad()". In I do:


FolderTable folderTable = new FolderTable();
DocumentTable documentTable = new DocumentTable();

new GridDragSource(folderTable.getGrid());

DockPanel dock = new DockPanel();
dock.add(documentTable, DockPanel.CENTER);
dock.add(footerFlowPanel, DockPanel.SOUTH);

where folderTable.getGrid() basically gets the grid object created from the "protected void onRender(Element parent, int index)" method. However the grid object which is instantiated in this method is not yet constructed (ie null). How is this generally coded? Is the instantiation code done in the constructor or on the onRender method? To me it seems that the onRender method is spawned off asynch...

Regards,
Steph

FollowSteph.com
18 Aug 2009, 10:18 AM
I just discovered that if I changed the class extension from ContainerLayout to ContentPanel and put the code in the constructor it worked great.

Why is that? What's the difference?

Regards,
Steph

fangzhouxing
30 Oct 2009, 4:07 PM
Anyone can explain the difference between constructor and onRender method, when should I put code in constructor, and when should I put code in onRender method?