PDA

View Full Version : OnRender and constructor



blay
6 Dec 2010, 11:06 AM
Maybe it´s a so basic question, but I hadn´t realized of this until now.
When I create a new widget which extends a LayoutContainer or a ContentPanel, etc, sometimes I defined a new constructor, sometimes override the onRender method. Both cases it seems to work right, but I know I´m not doing it as it should be done; because I suppouse each method has it pourpouse. So, can anyone explain me the differences between using one method or the other one? Or at least, what onRender should be used for and what the constructor should be used for

Thanks

sven
6 Dec 2010, 11:11 AM
Both work fine. Its up to you where you want to do it. onRender gets only called with the component gets really used. So if you create extra objects, they are only created when the component gets rendered.

shingocat
16 Nov 2011, 9:27 PM
Basically GXT suggest us to extend super class overriding the onRender() method.
it is for lazy rendering.
and on constructor is also ok, just not follow the GXT standard, I thought.
both ways are work well.