AnsweredAssumed Answered

Activiti-explorer and Vaadin

Question asked by variag on Feb 1, 2012
Latest reply on Jul 22, 2014 by jbarrez
Hello community,

I'm doing the first steps with Vaadin in activiti-explorer. I want insert in my form a button that if is clicked show a new window. This is my code:

public class CongressButton extends VerticalLayout{

   private static final long serialVersionUID = 1L;
   private Button open;
   private Window subwindow;
   
   public CongressButton(){
            super();
              // Create the window
              subwindow = new Window("A subwindow");

              // Configure the windws layout; by default a VerticalLayout
              VerticalLayout layout = (VerticalLayout) subwindow.getContent();
              layout.setMargin(true);
              layout.setSpacing(true);

              // Add some content; a label and a close-button
              Label message = new Label("This is a subwindow");
              subwindow.addComponent(message);

              Button close = new Button("Close", new Button.ClickListener() {
                  // inline click-listener
                  public void buttonClick(ClickEvent event) {
                      // close the window by removing it from the parent window
                      (subwindow.getParent()).removeWindow(subwindow);
                  }
              });
              // The components added to the window are actually added to the window's
              // layout; you can use either. Alignments are set using the layout
              layout.addComponent(close);
              layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

              // Add a button for opening the subwindow
              open = new Button("Open subwindow", new Button.ClickListener() {
                  // inline click-listener
                  public void buttonClick(ClickEvent event) {
                      if (subwindow.getParent() != null) {
                          // window is already showing
                          getWindow().showNotification("Window is already open");
                      } else {
                          // Open the subwindow by adding it to the parent window
                          getWindow().addWindow(subwindow);
                      }
                  }
              });
              addComponent(open);
          }

   
   public Button getButton(){
      return open;
   }
   
}

But when I click the button the following error appears:

com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
   at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
   at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
   at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1193)
   at com.vaadin.ui.Button.fireClick(Button.java:539)
   at com.vaadin.ui.Button.changeVariables(Button.java:206)
   at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1299)
   at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1219)
   at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:735)
   at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
   at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NullPointerException
   at formsExtensions.CongressButton$2.buttonClick(CongressButton.java:54)

   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
   … 22 more

I got the code for a example of Vaadin demo page and works fine, but when I try run this in my BPMN appears this problem. I think that problem is caused because the VerticalLayout window (father window) doesn't know what is the father window but I don`t know how do that with activiti.

Thanks very much for your replies and sorry for my bad english!  :P
Bye!

Outcomes