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 :

Message d'erreur GWT/Eclipse


Sujet :

GWT et Vaadin Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 94
    Par défaut Message d'erreur GWT/Eclipse
    Bonjour, je débute et j'essaye de reproduire le calendrier que l'on trouve sur le site de GWT : ICI

    Voici le code complet qui n'est pas très long :
    (j'ai mis l'interface onInitialize à part dans le même projet)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    public @interface onInitialize {
     
    }
    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
     
    package com.client;
     
    import java.util.Date;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.event.logical.shared.ValueChangeEvent;
    import com.google.gwt.event.logical.shared.ValueChangeHandler;
    import com.google.gwt.i18n.client.Constants;
    import com.google.gwt.i18n.client.DateTimeFormat;
    import com.google.gwt.user.client.ui.DialogBox;
    import com.google.gwt.user.client.ui.HTML;
    import com.google.gwt.user.client.ui.Label;
    import com.google.gwt.user.client.ui.VerticalPanel;
    import com.google.gwt.user.datepicker.client.DateBox;
    import com.google.gwt.user.datepicker.client.DatePicker;
    import com.google.gwt.user.client.ui.Widget;
     
    public class Calendrier implements EntryPoint {
     
    	public static interface CwConstants extends Constants {
     
    	    String cwDatePickerBoxLabel();
    	    String cwDatePickerDescription();
    	    String cwDatePickerLabel();
    	    String cwDatePickerName();
    	  }
     
    	public void onModuleLoad() {
     
    		  final CwConstants constants;
    		  @SuppressWarnings("deprecation")
    		  public Widget onInitialize() { <--Syntax error on token "Widget", @ expected
    		    // Create a basic date picker
    		    DatePicker datePicker = new DatePicker();  <-- Illegal modifier for parameter datePicker; only final is permitted
    		    final Label text = new Label();
     
    		    // Set the value in the text box when the user selects a date
    		    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
    		      public void onValueChange(ValueChangeEvent<Date> event) {
     
    		        Date date = event.getValue();
    		        @SuppressWarnings("deprecation")
    				String dateString = DateTimeFormat.getMediumDateFormat().format(date);
    		        text.setText(dateString);
    		      }
    		    });
     
    		    datePicker.setValue(new Date(), true);
     
    		    @SuppressWarnings("deprecation")
    			DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
    		    DateBox dateBox = new DateBox();
    		    dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
     
    		    // Combine the widgets into a panel and return them
    		    VerticalPanel vPanel = new VerticalPanel();
    		    vPanel.add(new HTML(constants.cwDatePickerLabel()));
    		    vPanel.add(text);
    		    vPanel.add(datePicker);
    		    vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    		    vPanel.add(dateBox);
    		    return;
    		  } <-- Syntax error on token "}", delete this token
     
    	}
    }
    Donc comme vous pouvez le voir, j'ai 3 erreurs : lignes 32, 34 et 63 avec les messages ci-dessus qui ne me semble pas très cohérents. Pour l'accolade signalée en trop, bin non elle est pas en trop.

    Je cherche depuis un bon moment, si quelqu'un pourrait m'aider ?

  2. #2
    Membre éclairé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Janvier 2011
    Messages
    41
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2011
    Messages : 41
    Par défaut
    Bonjour

    D'une part onInitialize comme tu l'as crée n'est pas une interface, mais une annotation:
    http://adiguba.developpez.com/tutori...r/annotations/

    Ensuite tu ne devrais pas avoir besoin de cette méthode puisqu'elle est propre au projet showcase de GWT:
    http://www.docjar.com/docs/api/com/g...entWidget.html

    Je corrigerais comme cela:

    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
     
    public class Calendrier implements EntryPoint {
     
    	//	public static interface CwConstants extends Constants {
    	// 
    	//	    String cwDatePickerBoxLabel();
    	//	    String cwDatePickerDescription();
    	//	    String cwDatePickerLabel();
    	//	    String cwDatePickerName();
    	//	  }
     
    	public void onModuleLoad() {
     
    		//CwConstants constants = GWT.create(CwConstants.class);
    		// Create a basic date picker
    		DatePicker datePicker = new DatePicker(); 
    		final Label text = new Label();
     
    		// Set the value in the text box when the user selects a date
    		datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {
    			public void onValueChange(ValueChangeEvent<Date> event) {
     
    				Date date = event.getValue();
    				@SuppressWarnings("deprecation")
    				String dateString = DateTimeFormat.getMediumDateFormat().format(date);
    				text.setText(dateString);
    			}
    		});
     
    		datePicker.setValue(new Date(), true);
     
    		@SuppressWarnings("deprecation")
    		DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
    		DateBox dateBox = new DateBox();
    		dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
     
    		// Combine the widgets into a panel and return them
    		VerticalPanel vPanel = new VerticalPanel();
    		// vPanel.add(new HTML(constants.cwDatePickerLabel()));
    		vPanel.add(text);
    		vPanel.add(datePicker);
    		//vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    		vPanel.add(dateBox);
    		return;
    	} 
     
    }
    PS CwConstants est aussi propre a GWT showcase (phrases définies dans un fichier .properties)

  3. #3
    Membre confirmé
    Inscrit en
    Novembre 2007
    Messages
    94
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 94
    Par défaut
    Merci beaucoup pour ton aide, ça fonctionne. J'ai juste remplacé l'instruction 'return' par un RootPanel.get().add(vPanel);

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

Discussions similaires

  1. message d'erreur sous eclipse avec jdom
    Par kayenne77 dans le forum XML/XSL et SOAP
    Réponses: 13
    Dernier message: 03/07/2009, 14h11
  2. Message d'erreur (no JRE ou JDK) à l'install d'Eclipse-SDK-3.2.1
    Par Yagami_Raito dans le forum Eclipse Platform
    Réponses: 2
    Dernier message: 11/05/2007, 14h07
  3. Eclipse, jsp et message d'erreur à gogo
    Par mammouth_35 dans le forum Eclipse Java
    Réponses: 4
    Dernier message: 17/04/2007, 17h14
  4. Message d'erreur Eclipse
    Par figo7 dans le forum Eclipse C & C++
    Réponses: 1
    Dernier message: 29/03/2007, 14h33
  5. message d'erreur sur Eclipse
    Par habbou dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 09/11/2006, 14h18

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