Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Problems with RAP selection Event (.open method)
Problems with RAP selection Event (.open method) [message #1749419] Tue, 06 December 2016 14:31 Go to next message
Christian Hubrich is currently offline Christian HubrichFriend
Messages: 3
Registered: March 2015
Junior Member
I use Eclipse RAP to realize a web application. The following code throws a nullpointer exception during execution of the selection listender:

Link link = new Link(composite_2, SWT.NONE);
    link.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    link.setText("<a>Dokument erfassen</a>");
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {

            TestDialog dia = new TestDialog(getShell(),
                    SWT.APPLICATION_MODAL);
            dia.open(new DialogCallback() {
                public void dialogClosed(int returnCode) {
                    System.out.println("Stored file: ");
                }
            });
        }
    })


The exception Looks like this:
java.lang.NullPointerException
	org.eclipse.swt.widgets.Dialog.open(Dialog.java:212)
	de.sparrow.ui.SparrowStart$2.widgetSelected(SparrowStart.java:111)
	org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:263)
	org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:109)
	org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:687)
	org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:594)
	org.eclipse.swt.widgets.Display.executeNextEvent(Display.java:1217)
	org.eclipse.swt.widgets.Display.runPendingMessages(Display.java:1198)
	org.eclipse.swt.widgets.Display.safeReadAndDispatch(Display.java:1181)
	org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1173)
	org.eclipse.rap.rwt.internal.lifecycle.ProcessAction.execute(ProcessAction.java:29)
	org.eclipse.rap.rwt.internal.lifecycle.PhaseExecutor.execute(PhaseExecutor.java:38)
	org.eclipse.rap.rwt.internal.lifecycle.SimpleLifeCycle.execute(SimpleLifeCycle.java:46)
	org.eclipse.rap.rwt.internal.service.RWTMessageHandler.executeLifeCycle(RWTMessageHandler.java:57)
	org.eclipse.rap.rwt.internal.service.RWTMessageHandler.handleMessage(RWTMessageHandler.java:41)
	org.eclipse.rap.rwt.internal.remote.MessageChainElement.handleMessage(MessageChainElement.java:29)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.processMessage(LifeCycleServiceHandler.java:128)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.processUIRequest(LifeCycleServiceHandler.java:100)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.synchronizedService(LifeCycleServiceHandler.java:75)
	org.eclipse.rap.rwt.internal.service.LifeCycleServiceHandler.service(LifeCycleServiceHandler.java:66)
	org.eclipse.rap.rwt.engine.RWTServlet.handleValidRequest(RWTServlet.java:135)
	org.eclipse.rap.rwt.engine.RWTServlet.handleRequest(RWTServlet.java:117)
	org.eclipse.rap.rwt.engine.RWTServlet.doPost(RWTServlet.java:107)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

The code of the class TestDialog Looks like the following:

public class TestDialog extends Dialog {

/**
 * 
 */
private static final long serialVersionUID = 1L;


public TestDialog(Shell parent) {
    super(parent);
    // TODO Auto-generated constructor stub
}


public TestDialog(Shell parent, int style) {
    super(parent,style);
    // TODO Auto-generated constructor stub
}


If i use the MessageBox class instead of the class TestDialog, everything works fine.

Re: Problems with RAP selection Event (.open method) [message #1749422 is a reply to message #1749419] Tue, 06 December 2016 14:38 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
the NPE (at org.eclipse.swt.widgets.Dialog.open(Dialog.java:212)) is because "shell" is null. Please check what getShell method returns inside your selection listener.
Regards,
Ivan
icon7.gif  Re: Problems with RAP selection Event (.open method) [message #1749423 is a reply to message #1749422] Tue, 06 December 2016 14:43 Go to previous messageGo to next message
Christian Hubrich is currently offline Christian HubrichFriend
Messages: 3
Registered: March 2015
Junior Member
Tahnks for the fast answer. The method getShell() returns a valid shell object. I used a system out and the result was "Shell {}". Any other ideas? Thanks a lot Smile
Re: Problems with RAP selection Event (.open method) [message #1749498 is a reply to message #1749423] Wed, 07 December 2016 12:11 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
in your TestDialog you have to override the prepareOpen method. In prepareOpen you must create your dialog Shell. See ColorDialog as example.
HTH,
Ivan
Previous Topic:RAP SWT Browser widget LocationListener
Next Topic:Eclipse RAP - Architecture
Goto Forum:
  


Current Time: Tue Mar 19 03:10:27 GMT 2024

Powered by FUDForum. Page generated in 0.02707 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top