#1590 Simple GWT page loads perfectly in 2.13, but fails to load in 2.14

Latest SVN
closed
javascript (25)
5
2014-12-24
2014-03-28
No

This bug actually refers to version 2.14, but Milestone dropdown doesn't have this value, so I've chosen 'Latest SVN' one.

The problem is that I've just tried to load pretty simple GWT page and the result I was getting was incomplete. I've googled and found that people were having similar problems in years 2011 and 2012 and successfully solved them using options from this HtmlUnit FAQ:

http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork

but, in my case - neither of them is working... I have pretty simple GWT login page with logo, login & password fields and a button with specified ids. Here is the code:

public static void main(String[] args) {
    final WebClient client = new WebClient(CHROME);
    client.setAjaxController(new NicelyResynchronizingAjaxController());
    final HtmlPage page = client.getPage("http://localhost:8080/");
    while (client.waitForBackgroundJavaScript(60000) > 0) {
        synchronized (page) {
            page.wait(200);
        }
    }

    final HtmlInput loginElement = (HtmlInput) page.getElementById("userField");
    loginElement.type("user"); // <-- NPE
}

The interesting thing is that I tried to debug it in the Eclipse and after stepping into WebClient.getPage(String) method and digging there for a while, everything worked even without NicelyResyncingAjaxController or waitingForBackgroundJavaScript...

I tried to downgrade to version 2.13 and there above code works superb, so I believe there were some changes introduced in 2.14 which corrupted this.

Please also note that my simple GWT page is simple HTML with only one js module which creates these fields. The only special feature which may be relevant is that these fields are getting populated in the following java code:

public class LoginModule implements EntryPoint {

    @Override
    public final void onModuleLoad() {
        // onModuleLoad is called in onLoad or at least I believe so
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                // populating <body> with login, password and button fields
            }
        });
    }

}

As per Javadocs, 'Scheduler.get().scheduleDeferred' executes passed command after the browser event loop returns.

Hope this sheds some light...

Discussion

  • Ahmed Ashour

    Ahmed Ashour - 2014-05-30
    • assigned_to: Ahmed Ashour
     
  • Ahmed Ashour

    Ahmed Ashour - 2014-05-30

    Hi,

    with SVN snapshot, the below works:

    @Override
    public final void onModuleLoad() {
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                final Button sendButton = new Button("Hello");
                RootPanel.get().add(sendButton);
            }
        });
    }
    

    and

        WebClient webClient = new WebClient(BrowserVersion.CHROME);
        HtmlPage page = webClient.getPage("http://127.0.0.1:8888/Test.html");
        webClient.waitForBackgroundJavaScript(2000);
        System.out.println(page.asXml());
    

    The 'Hello' button is there

     
  • Ahmed Ashour

    Ahmed Ashour - 2014-05-30
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks