Re: UiBinder performances: widgets without ui:field still instantiate?
With ref to your question: "So am I right to think that I should never use widget inside UiBinder xml except if I have the attribute ui:field (in other words, except if I need it in the Java code)?" I don't think this can be true for me. In fact, I am glad that GWT compiler instantiates all the widgets in the ui.xml template even for widgets where the java code does not have a @UiField declaration. The reason is, I would have a hierarchy of widgets defined in ui.xml template and I would want the whole hierarchy generated but what if I only need to manipulate three of the widgets? Being a lazy programmer, I only annotate those three widgets with @UiField, because @UiField annotation helps me get a reference handle on those widgets. I really don't want to spend time annotating widgets that I don't wish to manipulate in my java code. But I should still want those unnamed widgets generated - otherwise, my whole ui structure would collapse. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: UiBinder performances: widgets without ui:field still instantiate?
If you place widgets in your UI binder template then the system will instantiate the appropriate widgets even if you don't refer later to them in your code. The system still needs to create them as they are required to render the HTML page and implement interactions with the user. As a rule, I try and use HTML direct and widgets when I need extra functionality or need to interact with a page element from my code. All my layout is done using divs with CSS markup. I never use the horizontal or vertical panel. For labels and fieldset's I just use native HTML. On Apr 15, 11:01 am, plcoirier wrote: > Thanks for your help. > > I guess, even after java -> javascript compilation, the first example > will still instantiate a javascript object for each widget, right? > > > > > > So am I right to think that I should never use widget inside UiBinder > > > xml except if I have the attribute ui:field (in other words, except if > > > I need it in the Java code)? > > > Its best to minimize usage of widgets when you can; there is always a cost > > associated with them. Specifically, VerticalPanel and HorizontalPanel almost > > always should be replaced with (or tables if you don't like semantic > > markup). > > > BUT I'm still wondering if once compiled to JS those instanciations are> > > translated to plain html. It's not clear in what you're saying if it's in > > > production or in development mode. > > > The code pasted was the intermediate, unoptimized java code that uibinder > > generates prior to java -> js compilation. It will undergo optimizations > > once the compiler acts on it, and the code will for sure be a lot more > > performant. > > > However, in general, innerHTML is much better performance wise than creating > > objects and adding them to DOM. So, even after the compiler finishes all > > optimizations, performance wise it will still lag behind inline html. > > > --Sri > > > On 15 April 2010 19:30, Christian Goudreau > > wrote: > > > > I don't know if you're right about thinking that there's still situation > > > where an HTMLPanel or layout panel, without uifield is the best way to go, > > > but I do know that we should use as often as possible html code instead of > > > widget for the very reason you exposed. > > > > BUT I'm still wondering if once compiled to JS those instanciations are > > > translated to plain html. It's not clear in what you're saying if it's in > > > production or in development mode. > > > > Christian > > > > On Thu, Apr 15, 2010 at 9:44 AM, plcoirier wrote: > > > >> With UiBinder, I thought that GWT compiler would prevent instantiation > > >> of widget with no ui:field attribute by directly inserting the html > > >> code of the widget. > > > >> In other words, I thought that: > > > >> > > >> Line > > >> 1 > > >> Line > > >> 2 > > >> > > > >> would give the same result as: > > > >> > > >> > > >> > > >> Line1 > > >> Line2 > > >> > > >> > > >> > > > >> But in the first case, it generates this Java code: > > >> com.google.gwt.user.client.ui.Label f_Label3 = > > >> (com.google.gwt.user.client.ui.Label) > > >> GWT.create(com.google.gwt.user.client.ui.Label.class); > > >> com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel2 = > > >> (com.google.gwt.user.client.ui.HorizontalPanel) > > >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); > > >> com.google.gwt.user.client.ui.Label f_Label5 = > > >> (com.google.gwt.user.client.ui.Label) > > >> GWT.create(com.google.gwt.user.client.ui.Label.class); > > >> com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel4 = > > >> (com.google.gwt.user.client.ui.HorizontalPanel) > > >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); > > >> com.google.gwt.user.client.ui.VerticalPanel f_VerticalPanel1 = > > >> (com.google.gwt.user.client.ui.VerticalPanel) > > >> GWT.create(com.google.gwt.user.client.ui.VerticalPanel.class); > > > >> f_Label3.setText("Line 1"); > > >> f_HorizontalPanel2.add(f_Label3); > > >> f_VerticalPanel1.add(f_HorizontalPanel2); > > >> f_Label5.setText("Line 2"); > > >> f_HorizontalPanel4.add(f_Label5); > > >> f_VerticalPanel1.add(f_HorizontalPanel4); > > > >> and the second case, it generates: > > >> com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 = new > > >> com.google.gwt.user.client.ui.HTMLPanel(" Line1 > > >> Line2 "); > > > >> So am I right to think that I should never use widget inside UiBinder > > >> xml except if I have the attribute ui:field (in other words, except if > > >> I need it in the Java code)? > > > >> Thanks, > > >> Pierre > > > >> -- > > >> You received this message because you are subscribed to the Google Groups > > >> "Google Web Toolkit" group. > > >> To post to this group, send email to google-web-tool...@goo
Re: UiBinder performances: widgets without ui:field still instantiate?
Thanks for your help. I guess, even after java -> javascript compilation, the first example will still instantiate a javascript object for each widget, right? > > So am I right to think that I should never use widget inside UiBinder > > xml except if I have the attribute ui:field (in other words, except if > > I need it in the Java code)? > > Its best to minimize usage of widgets when you can; there is always a cost > associated with them. Specifically, VerticalPanel and HorizontalPanel almost > always should be replaced with (or tables if you don't like semantic > markup). > > BUT I'm still wondering if once compiled to JS those instanciations are> > translated to plain html. It's not clear in what you're saying if it's in > > production or in development mode. > > The code pasted was the intermediate, unoptimized java code that uibinder > generates prior to java -> js compilation. It will undergo optimizations > once the compiler acts on it, and the code will for sure be a lot more > performant. > > However, in general, innerHTML is much better performance wise than creating > objects and adding them to DOM. So, even after the compiler finishes all > optimizations, performance wise it will still lag behind inline html. > > --Sri > > On 15 April 2010 19:30, Christian Goudreau > wrote: > > > > > I don't know if you're right about thinking that there's still situation > > where an HTMLPanel or layout panel, without uifield is the best way to go, > > but I do know that we should use as often as possible html code instead of > > widget for the very reason you exposed. > > > BUT I'm still wondering if once compiled to JS those instanciations are > > translated to plain html. It's not clear in what you're saying if it's in > > production or in development mode. > > > Christian > > > On Thu, Apr 15, 2010 at 9:44 AM, plcoirier wrote: > > >> With UiBinder, I thought that GWT compiler would prevent instantiation > >> of widget with no ui:field attribute by directly inserting the html > >> code of the widget. > > >> In other words, I thought that: > > >> > >> Line > >> 1 > >> Line > >> 2 > >> > > >> would give the same result as: > > >> > >> > >> > >> Line1 > >> Line2 > >> > >> > >> > > >> But in the first case, it generates this Java code: > >> com.google.gwt.user.client.ui.Label f_Label3 = > >> (com.google.gwt.user.client.ui.Label) > >> GWT.create(com.google.gwt.user.client.ui.Label.class); > >> com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel2 = > >> (com.google.gwt.user.client.ui.HorizontalPanel) > >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); > >> com.google.gwt.user.client.ui.Label f_Label5 = > >> (com.google.gwt.user.client.ui.Label) > >> GWT.create(com.google.gwt.user.client.ui.Label.class); > >> com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel4 = > >> (com.google.gwt.user.client.ui.HorizontalPanel) > >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); > >> com.google.gwt.user.client.ui.VerticalPanel f_VerticalPanel1 = > >> (com.google.gwt.user.client.ui.VerticalPanel) > >> GWT.create(com.google.gwt.user.client.ui.VerticalPanel.class); > > >> f_Label3.setText("Line 1"); > >> f_HorizontalPanel2.add(f_Label3); > >> f_VerticalPanel1.add(f_HorizontalPanel2); > >> f_Label5.setText("Line 2"); > >> f_HorizontalPanel4.add(f_Label5); > >> f_VerticalPanel1.add(f_HorizontalPanel4); > > >> and the second case, it generates: > >> com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 = new > >> com.google.gwt.user.client.ui.HTMLPanel(" Line1 > >> Line2 "); > > >> So am I right to think that I should never use widget inside UiBinder > >> xml except if I have the attribute ui:field (in other words, except if > >> I need it in the Java code)? > > >> Thanks, > >> Pierre > > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Google Web Toolkit" group. > >> To post to this group, send email to google-web-tool...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> google-web-toolkit+unsubscr...@googlegroups.com > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/google-web-toolkit?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google Web Toolkit" group. > > To post to this group, send email to google-web-tool...@googlegroups.com. > > To unsubscribe from this group, send email to > > google-web-toolkit+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/google-web-toolkit?hl=en.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Google Web T
Re: UiBinder performances: widgets without ui:field still instantiate?
> > So am I right to think that I should never use widget inside UiBinder > xml except if I have the attribute ui:field (in other words, except if > I need it in the Java code)? > Its best to minimize usage of widgets when you can; there is always a cost associated with them. Specifically, VerticalPanel and HorizontalPanel almost always should be replaced with (or tables if you don't like semantic markup). BUT I'm still wondering if once compiled to JS those instanciations are > translated to plain html. It's not clear in what you're saying if it's in > production or in development mode. > The code pasted was the intermediate, unoptimized java code that uibinder generates prior to java -> js compilation. It will undergo optimizations once the compiler acts on it, and the code will for sure be a lot more performant. However, in general, innerHTML is much better performance wise than creating objects and adding them to DOM. So, even after the compiler finishes all optimizations, performance wise it will still lag behind inline html. --Sri On 15 April 2010 19:30, Christian Goudreau wrote: > I don't know if you're right about thinking that there's still situation > where an HTMLPanel or layout panel, without uifield is the best way to go, > but I do know that we should use as often as possible html code instead of > widget for the very reason you exposed. > > BUT I'm still wondering if once compiled to JS those instanciations are > translated to plain html. It's not clear in what you're saying if it's in > production or in development mode. > > Christian > > > On Thu, Apr 15, 2010 at 9:44 AM, plcoirier wrote: > >> With UiBinder, I thought that GWT compiler would prevent instantiation >> of widget with no ui:field attribute by directly inserting the html >> code of the widget. >> >> In other words, I thought that: >> >> >>Line >> 1 >>Line >> 2 >> >> >> would give the same result as: >> >> >> >> >>Line1 >>Line2 >> >> >> >> >> But in the first case, it generates this Java code: >>com.google.gwt.user.client.ui.Label f_Label3 = >> (com.google.gwt.user.client.ui.Label) >> GWT.create(com.google.gwt.user.client.ui.Label.class); >>com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel2 = >> (com.google.gwt.user.client.ui.HorizontalPanel) >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); >>com.google.gwt.user.client.ui.Label f_Label5 = >> (com.google.gwt.user.client.ui.Label) >> GWT.create(com.google.gwt.user.client.ui.Label.class); >>com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel4 = >> (com.google.gwt.user.client.ui.HorizontalPanel) >> GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); >>com.google.gwt.user.client.ui.VerticalPanel f_VerticalPanel1 = >> (com.google.gwt.user.client.ui.VerticalPanel) >> GWT.create(com.google.gwt.user.client.ui.VerticalPanel.class); >> >>f_Label3.setText("Line 1"); >>f_HorizontalPanel2.add(f_Label3); >>f_VerticalPanel1.add(f_HorizontalPanel2); >>f_Label5.setText("Line 2"); >>f_HorizontalPanel4.add(f_Label5); >>f_VerticalPanel1.add(f_HorizontalPanel4); >> >> and the second case, it generates: >>com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 = new >> com.google.gwt.user.client.ui.HTMLPanel(" Line1 >> Line2 "); >> >> So am I right to think that I should never use widget inside UiBinder >> xml except if I have the attribute ui:field (in other words, except if >> I need it in the Java code)? >> >> Thanks, >> Pierre >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Web Toolkit" group. >> To post to this group, send email to google-web-tool...@googlegroups.com. >> To unsubscribe from this group, send email to >> google-web-toolkit+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/google-web-toolkit?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: UiBinder performances: widgets without ui:field still instantiate?
I don't know if you're right about thinking that there's still situation where an HTMLPanel or layout panel, without uifield is the best way to go, but I do know that we should use as often as possible html code instead of widget for the very reason you exposed. BUT I'm still wondering if once compiled to JS those instanciations are translated to plain html. It's not clear in what you're saying if it's in production or in development mode. Christian On Thu, Apr 15, 2010 at 9:44 AM, plcoirier wrote: > With UiBinder, I thought that GWT compiler would prevent instantiation > of widget with no ui:field attribute by directly inserting the html > code of the widget. > > In other words, I thought that: > > >Line > 1 >Line > 2 > > > would give the same result as: > > > > >Line1 >Line2 > > > > > But in the first case, it generates this Java code: >com.google.gwt.user.client.ui.Label f_Label3 = > (com.google.gwt.user.client.ui.Label) > GWT.create(com.google.gwt.user.client.ui.Label.class); >com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel2 = > (com.google.gwt.user.client.ui.HorizontalPanel) > GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); >com.google.gwt.user.client.ui.Label f_Label5 = > (com.google.gwt.user.client.ui.Label) > GWT.create(com.google.gwt.user.client.ui.Label.class); >com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel4 = > (com.google.gwt.user.client.ui.HorizontalPanel) > GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); >com.google.gwt.user.client.ui.VerticalPanel f_VerticalPanel1 = > (com.google.gwt.user.client.ui.VerticalPanel) > GWT.create(com.google.gwt.user.client.ui.VerticalPanel.class); > >f_Label3.setText("Line 1"); >f_HorizontalPanel2.add(f_Label3); >f_VerticalPanel1.add(f_HorizontalPanel2); >f_Label5.setText("Line 2"); >f_HorizontalPanel4.add(f_Label5); >f_VerticalPanel1.add(f_HorizontalPanel4); > > and the second case, it generates: >com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 = new > com.google.gwt.user.client.ui.HTMLPanel(" Line1 > Line2 "); > > So am I right to think that I should never use widget inside UiBinder > xml except if I have the attribute ui:field (in other words, except if > I need it in the Java code)? > > Thanks, > Pierre > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-tool...@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
UiBinder performances: widgets without ui:field still instantiate?
With UiBinder, I thought that GWT compiler would prevent instantiation of widget with no ui:field attribute by directly inserting the html code of the widget. In other words, I thought that: Line 1 Line 2 would give the same result as: Line1 Line2 But in the first case, it generates this Java code: com.google.gwt.user.client.ui.Label f_Label3 = (com.google.gwt.user.client.ui.Label) GWT.create(com.google.gwt.user.client.ui.Label.class); com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel2 = (com.google.gwt.user.client.ui.HorizontalPanel) GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); com.google.gwt.user.client.ui.Label f_Label5 = (com.google.gwt.user.client.ui.Label) GWT.create(com.google.gwt.user.client.ui.Label.class); com.google.gwt.user.client.ui.HorizontalPanel f_HorizontalPanel4 = (com.google.gwt.user.client.ui.HorizontalPanel) GWT.create(com.google.gwt.user.client.ui.HorizontalPanel.class); com.google.gwt.user.client.ui.VerticalPanel f_VerticalPanel1 = (com.google.gwt.user.client.ui.VerticalPanel) GWT.create(com.google.gwt.user.client.ui.VerticalPanel.class); f_Label3.setText("Line 1"); f_HorizontalPanel2.add(f_Label3); f_VerticalPanel1.add(f_HorizontalPanel2); f_Label5.setText("Line 2"); f_HorizontalPanel4.add(f_Label5); f_VerticalPanel1.add(f_HorizontalPanel4); and the second case, it generates: com.google.gwt.user.client.ui.HTMLPanel f_HTMLPanel1 = new com.google.gwt.user.client.ui.HTMLPanel(" Line1 Line2 "); So am I right to think that I should never use widget inside UiBinder xml except if I have the attribute ui:field (in other words, except if I need it in the Java code)? Thanks, Pierre -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.