IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

GWT et Vaadin Java Discussion :

GWT tutorial de Moritan - probleme


Sujet :

GWT et Vaadin Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 213
    Par défaut GWT tutorial de Moritan - probleme
    Bonjour,

    J'en suis a l'etape ou je doit utilisé le service!
    donc tout fonction jusque la!

    voila ma classe
    ContactData :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
     
    package test.gwt.server;
     
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
     
    import test.gwt.client.util.Contact;
     
    public class ContactData {
     
    	public static Contact[] getAllContacts()
    	{
    		String query = "Select nom, prenom, telephone, mail from contact";
    		Contact[] contacts = new Contact[9]; //9 c'est le nombre ligne de ma table!
     
    		try {
    			Connection conn;
    			try {
    				Class.forName("com.mysql.jdbc.Driver").newInstance();
    			} catch (InstantiationException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (IllegalAccessException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			} catch (ClassNotFoundException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    			conn = DriverManager.getConnection(
    					"jdbc:mysql://localhost:3306/gwt", "root", "***");
    			Statement stmt = conn.createStatement();
    			ResultSet results = stmt.executeQuery(query);
    			int i = 0;
    			while(results.next())
    			{
    				contacts[i]=new Contact(results.getString("nom"),
    						results.getString("prenom"),
    						results.getString("mail"),
    						results.getString("telephone"));
    				i++;
    			}
    			stmt.close();
    			conn.close();
    		} catch (SQLException e) {
    			System.out.println("SQLException: " + e.getMessage());
    			System.out.println("SQLState: " + e.getSQLState());
    			System.out.println("VendorError: " + e.getErrorCode());
    		}
     
    		return contacts;	
    	}
     
    	public static void main(String[] args) {
    		Contact[] c = ContactData.getAllContacts();
     
    		for(int i=0;i<c.length;i++)
    		{
    			System.out.println(c[i].getNom()+" "+c[i].getPrenom()+" "+c[i].getEmail()+" "+c[i].getTel());
    		}
    	}
    }
    le main c'est pour tester si sa me renvoye bien les contact dans ma base
    donc le main marche mais quand je lance l'appli avec "monappli-shell.cmd"

    hors quand dans ContactData je mets

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
     
    package test.gwt.server;
     
    import test.gwt.client.util.Contact;
     
    public class ContactData {
     
    	public static Contact[] getAllContacts()
    	{
    		Contact[] contacts = new Contact[]{
    			    new Contact("Paul","Mc Cartney","@dvp.com","12"),
    			    new Contact("Ringo","Starr","@dvp.com","12"),
    			    new Contact("Yoko","Uno","@dvp.com","12"),
    			    new Contact("Bob","Dilan","@dvp.com","12"),
    			    new Contact("Ludwig","Von Beethoven","@dvp.com","12"),
    			    new Contact("Georges","Harrison","@dvp.com","12"),
    			    new Contact("Dick","Annegarn","@dvp.com","12"),
    			    new Contact("John","Lennon","@dvp.com","12")};		
    		return contacts;
    	}
     
    }
    et la ca marche aider moi!

  2. #2
    NoP
    NoP est déconnecté
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    35
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2005
    Messages : 35
    Par défaut
    Tu as un log ou une Trace ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 213
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [ERROR] Uncaught exception escaped
    java.lang.NullPointerException: null
    	at test.gwt.client.panel.ContactsPanel.filtre(ContactsPanel.java:63)
    	at test.gwt.client.panel.ContactsPanel$1.onSuccess(ContactsPanel.java:82)
    	at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:217)
    	at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:254)
    	at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:226)
    	at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:217)
    	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    	at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
    	at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    	at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    je vous balance ControlePanel

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    package test.gwt.client.panel;
     
    import test.gwt.client.ContactService;
    import test.gwt.client.ContactServiceAsync;
    import test.gwt.client.util.Contact;
     
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.user.client.rpc.AsyncCallback;
    import com.google.gwt.user.client.rpc.ServiceDefTarget;
    import com.google.gwt.user.client.ui.FlexTable;
    import com.google.gwt.user.client.ui.VerticalPanel;
     
    public class ContactsPanel extends VerticalPanel {
     
    	private FlexTable t = new FlexTable();
    	private Contact[] contacts = new Contact[0];
    	public static ContactsPanel instance;
     
    	public ContactsPanel() {
    	    getAllContacts();
    	    t.setTitle("Contacts");	
    	    t.setText(0, 0,"Nom");
    	    t.setText(0, 1,"Prénom");
    	    t.setText(0, 2,"Email");
    	    t.setText(0, 3,"Tel");
    	    t.setWidth("100%");
    	    t.setCellSpacing(2);
     
    	    for (int i = 0; i < 4; i++) {
    	    	 t.getCellFormatter().addStyleName(0, i, "contact-ContactPanel");
    		}
     
    	    this.add(t);
    	    this.setWidth("100%");
    	    instance=this;
    	 }
     
    	private void addContact(Contact contact,int i) {
    	    t.setText(i, 0,contact.getNom());
    	    t.setText(i, 1,contact.getPrenom());
    	    t.setText(i, 2,contact.getEmail());
    	    t.setText(i, 3,contact.getTel());
     
    	    for (int j = 0; j < 4; j++) {
    	    	if(i%2==0)
    	    		t.getCellFormatter().addStyleName(i, j, "contact-ContactPanel-line1");
    	    	else
    	    		t.getCellFormatter().addStyleName(i, j, "contact-ContactPanel-line2");	
    		}
    	}
     
    	public void filtre(){
    		String nom = RecherchePanel.instance.getNom();
    		String prenom = RecherchePanel.instance.getPrenom();
    		for (int i = t.getRowCount()-1; i >0 ; i--) {
    			t.removeRow(1);
    		}
    		int next =1;
    	    for (int i = 0; i < contacts.length; i++)
    	    {
    		 Contact contact =contacts[i];
     
    		 if (contact.getNom().toUpperCase().startsWith(nom.toUpperCase()) && contact.getPrenom().toUpperCase().startsWith(prenom.toUpperCase())) {
    			 addContact(contact,next);
    			 next++;
    		 }
    	    }
    	}
     
    	private void getAllContacts(){
    		//		 define the service you want to call
    	    ContactServiceAsync svc =
    	        (ContactServiceAsync) GWT.create(ContactService.class);
    	    ServiceDefTarget endpoint = (ServiceDefTarget) svc;
    	    String moduleRelativeURL = GWT.getModuleBaseURL() + "contactService";
    	    endpoint.setServiceEntryPoint(moduleRelativeURL);
     
    	    AsyncCallback callback = new AsyncCallback() {
    	      public void onSuccess (Object result)
    	      {
    	       contacts = (Contact[])result;
    	       filtre();
    	      }
     
    	      public void onFailure (Throwable ex)
    	      {
    	    	  contacts = new Contact[0];
     
    	    	  filtre();
    	      }
    	    };
     
    	    // execute the service
    	    svc.getAllContacts(callback);
     
    	  }
    }
    voila

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 213
    Par défaut
    Par un ptit test debile je me suis rendu compte que le service me retournais un tableau de 9 element "null"
    pour tant dans le test du mail j'ai bien le resultat que je souhaite!

    Edit :

    SQLException: No suitable driver found for jdbc:mysql://localhost:3306/gwt
    SQLState: 08001

    comme erreur pour le path est correcte!

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    213
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 213
    Par défaut
    lool

    bon j'ai essayé avec le plugin cipal studio pour eclipse et sa marche!!
    j'ai rien changer dans le code c'est ca le plus surprenant!
    enfin bon c'est pas grave sa devrait etre bon maintenant
    merci d'avoir pris la peine de lire le code!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme Google GWT connexion base de donne
    Par r0nsync dans le forum Webdesign & Ergonomie
    Réponses: 6
    Dernier message: 26/09/2008, 18h05
  2. GWT - Probleme de diffusion en mode web
    Par sboober dans le forum GWT et Vaadin
    Réponses: 13
    Dernier message: 24/08/2007, 15h13
  3. probleme cypal studio plugin eclipse GWT
    Par nicotoni dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 09/05/2007, 14h07
  4. probleme avec BDD et tutorial
    Par jean-marc2 dans le forum Flash
    Réponses: 6
    Dernier message: 02/11/2006, 09h36
  5. Débutant probleme au niveau "tutorial java"
    Par carton dans le forum Java ME
    Réponses: 3
    Dernier message: 22/07/2006, 09h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo