I can't seem to get my async callback to fire. I don't get it.

What I'm trying to do is get information from a database, through a
server side service (ToolServiceImpl, not shown here as I know it
works) and then use the keys in the resulting HashMap to populate Tab
Bars.

When I execute it, my temporary loading gif loads, everything appears
to execute, I see information from the database calls displaying, but
then onSuccess (or onFailure) never seem to do anything, even when
debugging messages are put in there.



CODE:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta name='gwt:module' content='com.acme.Main=com.acme.Main'>
        <title>Main</title>
    </head>
    <body>
        <script language="javascript"
        src="com.acme.Main/com.acme.Main.nocache.js"></script>
        <h2>Application</h2>
        <div id="loading">Loading, please wait....<br/>
           <img src="img/ajax-loader.gif"  alt="loading">
        </div>
        <div id="main">
        </div>


    </body>
</html>



CODE:

package com.acme.client;
import ...;


public class MainEntryPoint implements EntryPoint {


    public void onModuleLoad() {

        final String tool = "mytool";

        ToolBuilder builder = new ToolBuilder(tool);
        builder.buildNavigation(new ToolBuildHandler() {
            public void onBuilt(Widget widget) {

                HorizontalPanel panel = new HorizontalPanel();
                panel.add(widget);


                RootPanel.get().add(panel);
            }

            public void onFailure() {
                throw new RuntimeException("Loading "+tool+" failed");
            }
        });



    }
}



CODE:

package com.acme.client.tool;


import ...;
import com.acme.client.ToolService;
import com.acme.client.ToolServiceAsync;


public class ToolBuilder {

    private final String tool;

    public ToolBuilder(String tool) {
        this.tool = tool;
    }

    protected Widget getNavigation(HashMap result) {

        String tool = "null";
        final HashMap r;
        final HashMap ee = new HashMap();
        final VerticalPanel mainPanel = new VerticalPanel();
        final TabPanel gadgetTabs = new TabPanel();

        try {
            DOM.setInnerHTML(RootPanel.get("loading").getElement(),
"");

            if(tool.equalsIgnoreCase("mytool")) {


                r = (HashMap)result;

                Iterator it = r.keySet().iterator();
                while (it.hasNext()) {
                    String nameOfObj = (String)it.next();

                    MyTab myTab = new MyTab();

                    gadgetTabs.add(myTab, nameOfObj);

                }
                mainPanel.add(gadgetTabs);

                gadgetTabs.addSelectionHandler(new SelectionHandler()
{
                    public void onSelection(SelectionEvent event) {
                        // Let the user know what they just did.
                        Window.alert("You clicked tab " +
event.getSelectedItem());
                    }
                });
            }
        } catch(Exception e) {
                    System.out.println("Exception:"+e.toString());
        }
        return mainPanel;
    }



    public void buildNavigation(final ToolBuildHandler handler) {

        AsyncCallback callback = new AsyncCallback() { // THIS NEVER
APPEARS TO WORK

            public void onSuccess(Object result) {
                handler.onBuilt(getNavigation((HashMap)result));
            }


            public void onFailure(Throwable arg0) {
                System.out.println("Failed to execute tool");
            }

        };
        getService().myMethod(tool,callback); // THIS WORKS
    }
    public static ToolServiceAsync getService() {
        ToolServiceAsync service = (ToolServiceAsync) GWT.create
(ToolService.class);

        ServiceDefTarget endpoint = (ServiceDefTarget) service;
        String moduleRelativeURL = GWT.getModuleBaseURL() + "metrics/
toolservice";
        endpoint.setServiceEntryPoint(moduleRelativeURL);
        return service;

    }
}



CODE:

package com.acme.client.tool;

import com.google.gwt.user.client.ui.Widget;

public interface ToolBuildHandler {
    public void onBuilt(Widget widget);
    public void onFailure();
}



CODE:

package com.acme.client.metrics;
import com.google.gwt.user.client.rpc.AsyncCallback;

public interface ToolServiceAsync {
    public void myMethod(String s,AsyncCallback callback);
}



CODE:

package com.acme.client.metrics;

import com.google.gwt.user.client.rpc.RemoteService;
import java.util.HashMap;

public interface ToolService extends RemoteService{
    public HashMap myMethod(String s);
}



CODE:

package com.acme.client.tool;

import ...;


public class MyTab extends DeckPanel {

    HashMap myHashMap;

    public MyTab() {


        final Label text = new Label();
        Button button = new Button("Click me!");

        HTMLTable table = new Grid(5, 5);

        for (int row = 0; row < 5; ++row) {
            for (int col = 0; col < 5; ++col) {
                table.setText(row, col, "" + row + ", " + col);
            }
        }

        button.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.alert("Hello, again");
            }


        });
    }
}

--~--~---------~--~----~------------~-------~--~----~
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