On Dec 9, 6:26 am, Ross McKinnon <[email protected]> wrote:
> HI there, the window is essentially a popup window created using the
> Window() class, so is not a separate browser window. Currently I only
> have the results stored in an ArrayList but i want to pass it back to
> my class that contains all the main page components?

You can use the EventBus and throw an event with your data, and
register
your main app page on the event and do something with it.

First create the event:

public interface SearchCompletedHandler extends EventHandler
{
        void onSearchCompleted(SearchCompletedEvent event);
}

public class SearchCompletedEvent extends
GwtEvent<SearchCompletedHandler>
{
        public static final Type<SearchCompletedHandler> TYPE = new
Type<SearchCompletedHandler>();

        private MySearchData data;

        public SearchCompletedEvent(MySearchData data)
        {
                this.data = data;
        }

        @Override
        protected void dispatch(SearchCompletedHandler handler)
        {
                handler.onSearchCompleted(this);
        }

        @Override
        public Type getAssociatedType()
        {
                return TYPE;
        }

        public MySearchData getData() { return data; }
}


In your Main App, say in onModuleLoad():
        eventBus = new EventBus();  // or HandlerManager(null) in pre-2.1
        eventBus.addHandler(SearchCompletedEvent.TYPE, this);

Make your app page implement SearchCompletedHandler:
public class MyClass implements SearchChangedHandler
{
    ...
        public void onPlaceChanged(SearchCompletedEvent event)
        {
              MySearchData data = event.getData();
              // show the data
        }
}

Finally, in the search popup, fire the event when you're ready for it
to display:
        MySearchData data = searchResultsFromServer();
        eventBus.fireEvent(new SearchCompletedEvent(data));


HTH,
Harold

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to