Newbie question:ClickEvent

Hi,
It’s the first time that i use vaadin under eclipse IDE and MS windows XP .
I have some probleme with the button code i didn’t understand what’s the matter

Here is my code that i found in the book-of-vaadin:


package com.example.myproject;
import com.vaadin.Application;
import com.vaadin.ui.*;
public class MyprojectApplication extends Application
{
@Override
public void init() {
final Window mainWindow =
new Window("Myproject Application");
Label label = new Label("Hello Vaadin user");
mainWindow.addComponent(label);
mainWindow.addComponent(
new Button("What is the time?",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
mainWindow.showNotification(
"The time is " + new Date());
}
}));
setMainWindow(mainWindow);
}

After running the code I obtain the following Error :

Etat HTTP 500 -


type Rapport d’exception

message

description Le serveur a rencontré une erreur interne () qui l’a empêché de satisfaire la requête.

exception

javax.servlet.ServletException: java.lang.Error: Unresolved compilation problems:
The type new Button.ClickListener(){} must implement the inherited abstract method Button.ClickListener.buttonClick(Button.ClickEvent)
Date cannot be resolved to a type

com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:973)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:530)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

cause mère

java.lang.Error: Unresolved compilation problems:
The type new Button.ClickListener(){} must implement the inherited abstract method Button.ClickListener.buttonClick(Button.ClickEvent)
Date cannot be resolved to a type

com.example.myproject.MyprojectApplication.init(MyprojectApplication.java:15)
com.vaadin.Application.start(Application.java:554)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1182)
com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:466)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/6.0.14.


Apache Tomcat/6.0.14

I’m using Vaadin 6.5.2
I hope some one can help, I’d really like to start using Visualizations with Vaadin.
Thanks!

hi i have the same error !! i do just copy/past from the book-of-vaadin !! :blink:

The problem is that you are missing some imports: the classes com.vaadin.ui.Button.ClickEvent and java.util.Date are not imported. For Date, this is quite clear if you read the other error messages, but for Button.ClickEvent not so clear from the messages. Either use “Button.ClickEvent” for the parameter or explicitly import com.vaadin.ui.Button.ClickEvent.

Unfortunately, Eclipse is not very good at completing imports for anonymous inner classes, and might sometimes even remove some imports if others are missing or incorrect and you ask Eclipse to reorganize imports.

I still waiting for some one who respond me,special thanks for you Henri i’m so happy for your attention :slight_smile:
the code has worked well