Hybrid View

  1. #1
    Ext User
    Join Date
    Nov 2008
    Location
    Switzerland
    Posts
    103
    Vote Rating
    0
    googelybear is on a distinguished road

      0  

    Default How to properly implement custom widgets: onRender vs constructor?

    How to properly implement custom widgets: onRender vs constructor?


    Hello everyone,

    I'm currently evaluating gxt and for that purpose I want to create some new widgets. These widgets are just composed of existing widgets. E.g. I subclass a layout container and add some content panels and into them some other widgets.
    What I am currently confused is whether I should populate these widgets in the constructor (gwt style) or in the onRender() method. I browsed through the examples and read in the help center, but I could not get a concise answer (sometimes it's done in the constructor, sometimes in onRender()). So what's the proper way to do this?

  2. #2
    Ext User
    Join Date
    Oct 2008
    Location
    Warsaw(PL)/Cottbus(GER)
    Posts
    215
    Vote Rating
    0
    EagleEye666666 is on a distinguished road

      0  

    Default


    Quote Originally Posted by googelybear View Post
    Hello everyone,

    I'm currently evaluating gxt and for that purpose I want to create some new widgets. These widgets are just composed of existing widgets. E.g. I subclass a layout container and add some content panels and into them some other widgets.
    What I am currently confused is whether I should populate these widgets in the constructor (gwt style) or in the onRender() method. I browsed through the examples and read in the help center, but I could not get a concise answer (sometimes it's done in the constructor, sometimes in onRender()). So what's the proper way to do this?
    good and interesting question, I am using the constructor. I didn't think about it a lot neither dig around. Iam looking forward to more qualified answers hehe

    regards

  3. #3
    Ext User
    Join Date
    Nov 2008
    Location
    Switzerland
    Posts
    103
    Vote Rating
    0
    googelybear is on a distinguished road

      0  

    Default


    Apparently it's just the two of us wondering how this is done properly ;-(
    Did you already find a solution?
    I'm currently creating the static structure inside the constructor and add the actual data displayed in the widget later on in a custom method, followed by a layout() call to ensure it's updated correctly.

  4. #4
    Ext User
    Join Date
    Nov 2008
    Posts
    41
    Vote Rating
    0
    edfimasa is on a distinguished road

      0  

    Default


    Hi.

    I sometimes using the Constructor when i don't need to get the elements from the DOM, when i need to get the DOM i build inside onRender. The layout() doesn't workout very well for me inside the constructor, don't know why.

    But, i also would like to know the best practice.

    Cheers.

  5. #5
    Ext User fother's Avatar
    Join Date
    Sep 2007
    Location
    Brazil
    Posts
    744
    Vote Rating
    -1
    fother is an unknown quantity at this point

      0  

    Default


    if you create at constructor the widget will be created when the class is instanced.

    and when you create at the method onRender() the widget will be created for lazy rendered components.

    but for example.. if you create a class that extends a tab item.. if the tab will be close or not.. you need set in the constructor..

    I'm using in onRender() to create my view how to the explorer.

  6. #6
    Ext User
    Join Date
    Oct 2008
    Posts
    126
    Vote Rating
    0
    LINEMAN78 is on a distinguished road

      0  

    Default


    It all depends on what you are trying to do... If you are trying to use some sort of external library that relies on accessing the DOM in order to render something (i.e. swfobject.js) you will need to use the onLoad() method. I have found that if this is not the case, it tends to work best if you stick with the constructor method(less memory leaks). When you are using the onRender method, remember you will have to make sure you have error checking to see if the object has been drawn before calling any functions on it. If the object has not been rendered, you can simply change the parameters that the object will be rendered to. However, if the object has been rendered, you will need to perform changes to the object in the DOM, or change the perameters and redraw. When using the onLoad method, don't forget to also override the onUnload method to destroy your object and eliminate memory leaks.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi