Class com.vaadin.event.ListenerMethod can not access a member of class....

Hi,

I have an error: “Class com.vaadin.event.ListenerMethod can not access a member of class … with modifiers “public””

My code is:

table.addListener( new ItemClickListener()
{
public void itemClick(final ItemClickEvent event)
{

Window details = new Window();

MyDetails d = new MyDetails(getDbHelp());
d.details.saveButton.addListener(Button.ClickEvent.class, this, “save”);

}
public void save(Button.ClickEvent e)
{

}
});

I wrote just the most important lines of the code. It is strange why i get this error? My class save has a modifier “public”. How to solve that?

Thank you in advance.

Your anonymous ItemClickListener class is not public.

Using the addListener method that uses reflection based on a method name has turned out to be a very fragile practice and should have been removed from the framework a long time ago if it wasn’t for the issue of maintaining backwards compatibility.

See
http://dev.vaadin.com/ticket/7848
and the other tickets mentioned in the comments for more details.

I read those tickets but didn’t know how to solve and adopt those workarounds to my example. Maybe can someone help? :slight_smile: I don’t know how to change my code…

The easiest way is to replace

d.details.saveButton.addListener(Button.ClickEvent.class, this, "save");}

with code that instead creates a ClickListener instances, e.g. something like this

d.details.saveButton.addListener(new Button.ClickListener() {
  public void buttonClick(ClickEvent event) {
    save();
  }
});