my dog learned polymorphism*
The moose likes GWT and the fly likes comprehension problem gwt & events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "comprehension problem gwt & events" Watch "comprehension problem gwt & events" New topic
Author

comprehension problem gwt & events

Artur Wojciechowski
Greenhorn

Joined: Feb 01, 2011
Posts: 1

Hi
I'm new to GWT. At the moment I'm reading the tutorial for the
StockWatcher (http://code.google.com/intl/de-DE/webtoolkit/doc/latest/
tutorial/codeclient.html).
Here is the code I do not understand:



At the first line a new Button is created. Afterwards the button gets
a new anonymous ClickHandler with the "onClick()" function. So far so
good.
But when the user clicks the button and the "onClick()" function is
called, how is it possible, that the String variable "symbol" still
lives in memory?
I have implemented this code to my eclipse and it works perfectly. But
I do not understand how is it possible to get the value of the
"symbol" variable after the button has been created and sent to
client.??? When user clicks on the button the "onClick()" function is
called and still has the value of the "symbol" string??'
Can someone explain it to me?
Thanks
Artur
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

Welcome to the Ranch.
The variable symbol is referenced by stocks.indexOf(symbol); Hence it is not garbage collected and available when the onClick executes


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: comprehension problem gwt & events