Editing in popup window

Hi
I am new to Vaadin, trying to learn it. I followed the recorded webinar of Geertjan Wielenga and Matti Tahvonen on
“Java EE 7 with NetBeans and Vaadin” (https://www.youtube.com/watch?v=3TompuzySD8).

The interface customer works well but when I tried to write and run the discountCodeTableViewWithPopup, it is displayed as table but when I click a record in the table, it doesn`t popup the editing popup and etting the following exceptions. Any help will be appreciated.

com.vaadin.event.ListenerMethod$MethodException: Invocation of method valueChange in com.vaadin.cdi.example.view.DiscountCodeTableViewWithPopup$$Lambda$10/1060613452 failed. at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:528) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:969) at org.vaadin.maddon.fields.MTable.fireValueChange(MTable.java:108) at com.vaadin.ui.AbstractField.setValue(AbstractField.java:542) at com.vaadin.ui.AbstractSelect.setValue(AbstractSelect.java:702) at com.vaadin.ui.AbstractSelect.changeVariables(AbstractSelect.java:521) at com.vaadin.ui.Table.changeVariables(Table.java:2880) at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:396) at com.vaadin.server.communication.ServerRpcHandler.handleBurst(ServerRpcHandler.java:221) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:111) at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:91) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1387) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at

Is this with some code available somewhere? The class does not seem to be part of the
CDI example at Github
at least.

Is that Java 8 code? It looks like there’s some problem with a lambda expression. It’s hard to say what could cause that without seeing some code. You could change the lambda expression to a listener if it gives more clear explanation.

Hi Marko
Thanks for your reply. Here is the class file that I forgot to attach earlier. Thanks for your comments.
Mortoza

@CDIView(“discountCode”)
public class DiscountCodeTableViewWithPopup extends MVerticalLayout implements View {
@Inject
DiscountCodeFacade cf;

@Inject
DiscountCodeForm form;

MTable<DiscountCode> table = new MTable<>(DiscountCode.class);

private Window popup;


@PostConstruct
public void initComponent(){
    popup=new Window("discount code", form);
    popup.setModal(true);
    form.setResetHandler(this::reset);
    form.setSavedHandler(this:: save);
    
    table.addMValueChangeListener(e->{
        if(e.getValue() !=null){
            form.setEntity(e.getValue());
            getUI().addWindow(popup);
        }
    });
    
    listEntities();
    
    Button addButton = new Button("add");
    addButton.addClickListener(e->{
       form.setEntity(new DiscountCode());
       getUI().addWindow(popup);
    });
    
    addComponents(
            new Header("Discount Listing"),
            table,
            addButton
    );
}
      

private void listEntities(){
    table.setBeans(cf.findAll());
    
}

public void save(DiscountCode entity){
    if(entity.getDiscountCode()==null){
        cf.create(entity);
    }else{
        cf.edit(entity);
    }
    listEntities();
    Notification.show("Saved..!");
    
}

 public void reset(DiscountCode entity){
     popup.close();
     listEntities();
}


@Override
public void enter(ViewChangeListener.ViewChangeEvent event) {
   // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

Well, according to the stack trace, there was a problem with the value change listener. The error is a method exception, which could indicate that there was some trouble calling the listener. You could try using an anonymous class instead of the lambda expression if that could make the error more clear. There could also be a problem that occurred during the invocation - perhaps there’s a final cause later in the stack trace.

Thanks.