On Tuesday, January 7, 2014 1:41:14 PM UTC+1, Ed wrote: > > Why exactly are GWT widgets often labeled as "heavy"? > I understand that it has to do with the attached event (in the > Widget.onAttach() method), and that a Widget should only be used in case > you need DOM events, but what are exactly the heavy parts (details?) of a > Widget that make them "heavy"? >
The "heavy" part is "DOM manipulation" (createElement, appendChild, etc.). For simple widgets consisting of a single element, this is not really a problem until you start instantiating many of them; for more complex widgets, creating the original DOM structure can be much faster using innerHTML than creating each element individually. Attaching event handlers to a DOM element also has a cost, which is why event delegation should be preferred when applicable (again, for "complex screens", that means not using child widgets). One issue with many simple built-in widgets in GWT is that they register event handlers even when you don't handle any event yourself, just to be able to update the styles (focus, hover, etc.) Cell widgets (CellList, CellTable, etc.) use both innerHTML and event delegation. They're much faster than the same thing done with, say, a Grid and inner widgets (e.g. create a grid with 50 lines, add 1 text box into the first 2 columns on each line –that's 100 TextBox widgets–, and a button to the third column –another 50 PushButton widgets–, and then populate each text box with data coming from a list of objects; of course, you'd also register an event handle in each widget to update the corresponding/bound object). FYI, Renderable in GWT is/was an attempt at reconciling Widget objects with an innerHTML-created DOM. You'd still pay the cost of the event handlers but creating the initial DOM structure is just about an innerHTML, followed by a bunch of getElementById to get the elements back and associate them with their Widget object. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/groups/opt_out.
