Static widget

44 views
Skip to first unread message

Deepak Singh

unread,
Nov 21, 2012, 7:21:02 AM11/21/12
to google-we...@googlegroups.com
Hi,

I want to confirm that making a widget / variable as static generates more javascript code than non-static widget. Is that right?

If yes, then what is the possible way to handle the scenario where i need to access  the same widget instance throughout the application e.g. HeaderUiBinder should be same ?

Regards
Deepak Singh

Jens

unread,
Nov 21, 2012, 7:53:04 AM11/21/12
to google-we...@googlegroups.com
I think the generated code isn't that different so you should not care about it. Just make it static if you need to and trust the compiler. You can always try it yourself using a mini GWT project and compile it with style Pretty.

Not sure but I would guess its something like:

function MyWidget() {
   var myVar = 1; //member variable
}

versus

function MyWidget() {
}
MyWidget.myVar = 1; //"static" variable


Alternative would be to make your widget a singleton.

Just keep in mind that you can't insert the same widget instance in two different panels as each widget can only have one parent widget at any time. So when you add a widget instance a second time into a panel it removes itself from its current parent.

-- J.

Deepak Singh

unread,
Nov 21, 2012, 2:29:48 PM11/21/12
to google-we...@googlegroups.com
I also think the same.....



-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/RGxHNOC7OdwJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh
Reply all
Reply to author
Forward
0 new messages