2009-05-29 6 views
0

Je travaille sur un projet GWT et j'ai plusieurs services distants vides qui semblent s'exécuter très bien, mais du côté client, finissent par déclencher la méthode onFailure(). Aucune exception n'est lancée nulle part et le comportement attendu est observé sur le backend. Je n'ai aucune idée de ce qui pourrait mal tourner. Voici le code correspondant:GWT Les services distants vides échouent pour apparemment pas de raison

Interfaces et la mise en œuvre ...

@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(); 
     } 
    } 
} 

Indicatif téléphonique ...

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();     
       } 

      }); 
     } 
    } 

Je sais que je suis une secousse pour l'affichage comme 500 lignes de code, mais Je regarde ça depuis hier et je n'arrive pas à comprendre où je me trompe. Peut-être un 2e jeu d'yeux contribuerait ...

Merci, brian

+0

Quelle est la valeur de la variable capturée transmise à la méthode onFailure dans votre AsyncCallback? – Carnell

Répondre

0

LGTM J'ai peur. Etes-vous en mode hébergé ou un navigateur à part entière?

Vous pouvez essayer de changer et voir si cela aide.

En outre, il peut être utile d'écouter ce //TODO et d'effectuer un GWT.log lorsque onFailure est appelée.