0

我正在处理一个 GWT 项目,并且有几个无效的远程服务似乎执行得很好,但在客户端,最终触发了该onFailure()方法。任何地方都不会抛出异常,并且在后端观察到预期的行为。我不知道可能出了什么问题。以下是相关代码:

接口和实现...

@RemoteServiceRelativePath("DeleteSearchService")
public interface DeleteSearchService extends RemoteService {
    /**
     * Utility class for simplifying access to the instance of async service.
     */
    public static class Util {
        private static DeleteSearchServiceAsync instance;
        public static DeleteSearchServiceAsync getInstance(){
            if (instance == null) {
                instance = GWT.create(DeleteSearchService.class);
            }
            return instance;
        }
    }

    public void delete(SearchBean search);
}

public interface DeleteSearchServiceAsync {
    public void delete(SearchBean bean, AsyncCallback<Void> callback);
}

public class DeleteSearchServiceImpl extends RemoteServiceServlet implements DeleteSearchService {

    private static final long serialVersionUID = 1L;

    @Override
    public void delete(SearchBean search) {
        try {

            Connection conn = SQLAccess.getConnection();
            String sql = "DELETE FROM `searches` WHERE `id`=?";

            PreparedStatement ps = conn.prepareStatement(sql);
            ps.setInt(1, search.getSearchId());

            ps.execute();

            sql = "DELETE FROM `searchsourcemap` WHERE `search-id` = ?";

            ps = conn.prepareStatement(sql);
            ps.setInt(1, search.getSearchId());

            ps.execute();

            return;

        } catch (Exception e) {
            // TODO Log error
            e.printStackTrace();
        }
    }
}

调用代码...

private class DeleteListener implements ClickListener {
        public void onClick(Widget sender) {
            DeleteSearchServiceAsync dss = DeleteSearchService.Util.getInstance();

            SearchBean bean = buildBeanFromGUI();

            dss.delete(bean, new AsyncCallback<Void>(){

                //@Override
                public void onFailure(Throwable caught) {
                    // TODO log
                    SearchNotDeleted snd = new SearchNotDeleted();
                    snd.show();
                }

                //@Override
                public void onSuccess(Void result) {
                    SearchDeleted sd = new SearchDeleted();
                    sd.show();
                    searchDef.getParent().removeFromParent();                   
                }

            });
        }
    }

我知道我发布了 500 行代码是个混蛋,但我从昨天开始就一直盯着它看,不知道我哪里出错了。也许第二双眼睛会有所帮助......

谢谢,布赖恩

4

1 回答 1

0

LGTM 恐怕。

您使用的是托管模式还是成熟的浏览器?您可以尝试切换,看看是否有帮助。

此外,它可能有助于倾听//TODO并执行GWT.log何时onFailure被调用。

于 2009-05-29T20:39:49.317 回答