PDA

View Full Version : [CLOSED] Bug: Window.alignTo()



Cypher
18 Aug 2008, 7:50 AM
I'm not sure whether it is a bug or maybe there is something wrong with my code. When I call alignTo() on instance of Window widget, a "null pointer exception" is thrown. Without calling alignTo(), the code works as expected.

Here is the main code:


package com.test.popup.client;

import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;

public class Popup implements EntryPoint {
public void onModuleLoad() {
Element anchor = DOM.getElementById("anchor");

Window popup = new Window();
popup.setHeading("Test Window");
popup.setWidth(250);
popup.setBodyStyleName("pad-text");
popup.addText("Test...");
popup.alignTo(anchor, "bl-br", new int[]{2,2}); // <-----[ Error ]-----
popup.show();
}
}
And here is my host HTML page:



<html>
<head>
<title>Popup</title>
<link rel="stylesheet" type="text/css" href="css/ext-all.css" />
</head>
<body style="overflow:hidden">
<script language='javascript' src='com.test.popup.Popup.nocache.js'></script>
<div id="anchor">@@@</div>
</body>
</html>
Error message:


[ERROR] Unable to load module entry point class com.test.popup.client.Popup (see associated exception for details)
java.lang.NullPointerException: null
at com.extjs.gxt.ui.client.widget.Window.alignTo(Window.java:242)
at com.test.popup.client.Popup.onModuleLoad(Popup.java:18)
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.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:303)
at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:324)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access$200(BrowserWidgetIE6.java:37)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6.java:71)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.java:128)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
I tested this only in hosted mode, on Win XP with MSIE 6.0/SP2 and with GWT 1.5.0/Ext-GWT 1.0.2.

darrellmeyer
18 Aug 2008, 7:38 PM
This method should only be called after the window is visible. I have added some comments to the javadocs. Try this:


Window popup = new Window();
popup.setHeading("Test Window");
popup.setWidth(250);
popup.setBodyStyleName("pad-text");
popup.addText("Test...");
popup.show();
popup.alignTo(anchor, "bl-br", new int[]{2,2}); // <-----[ Error ]-----

Cypher
19 Aug 2008, 5:01 AM
Oh, perfect, Darrell, now it works! Thanks for such a prompt response!