]> source.dussan.org Git - vaadin-framework.git/commitdiff
Merge commit 'da31250280ded2b984382f15055a3e029b11a8a0'
authorArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 06:48:03 +0000 (08:48 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 06:48:03 +0000 (08:48 +0200)
Conflicts:
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java

1  2 
src/com/vaadin/terminal/gwt/client/ApplicationConnection.java

index ff5244a3c10b0d34c1615b7a9db9185fb5b28689,fa5f102f5eae2eab33356831cbd1651389aea5c0..71c2142461f7a9810d1ac0a9c2da62dc44e5bdf7
@@@ -218,19 -209,10 +218,19 @@@ public class ApplicationConnection 
       * failed to start. This ensures that the applications are started in order,
       * to avoid session-id problems.
       * 
 -     * @return
       */
      public void start() {
 -        repaintAll();
 +        String jsonText = configuration.getUIDL();
 +        if (jsonText == null) {
 +            // inital UIDL not in DOM, request later
 +            repaintAll();
 +        } else {
 +            // Update counter so TestBench knows something is still going on
 +            incrementActiveRequests();
 +
 +            // initial UIDL provided in DOM, continue as if returned by request
-             handleJSONText(jsonText);
++            handleJSONText(jsonText, -1);
 +        }
      }
  
      private native void initializeTestbenchHooks(
          if (!synchronous) {
              RequestCallback requestCallback = new RequestCallback() {
                  public void onError(Request request, Throwable exception) {
-                     showCommunicationError(exception.getMessage());
+                     showCommunicationError(exception.getMessage(), -1);
                      endRequest();
 -                    if (!applicationRunning) {
 -                        // start failed, let's try to start the next app
 -                        ApplicationConfiguration.startNextApplication();
 -                    }
                  }
  
                  public void onResponseReceived(Request request,
                      // for(;;);[realjson]
                      final String jsonText = response.getText().substring(9,
                              response.getText().length() - 1);
-                     handleJSONText(jsonText);
 -                    final ValueMap json;
 -                    try {
 -                        json = parseJSONResponse(jsonText);
 -                    } catch (final Exception e) {
 -                        endRequest();
 -                        showCommunicationError(e.getMessage()
 -                                + " - Original JSON-text:" + jsonText,
 -                                statusCode);
 -                        return;
 -                    }
 -
 -                    VConsole.log("JSON parsing took "
 -                            + (new Date().getTime() - start.getTime()) + "ms");
 -                    if (applicationRunning) {
 -                        handleReceivedJSONMessage(start, jsonText, json);
 -                    } else {
 -                        applicationRunning = true;
 -                        handleWhenCSSLoaded(jsonText, json);
 -                        ApplicationConfiguration.startNextApplication();
 -                    }
++                    handleJSONText(jsonText, statusCode);
                  }
  
              };
  
      }
  
-     private void handleJSONText(String jsonText) {
 +    /**
 +     * Handles received UIDL JSON text, parsing it, and passing it on to the
 +     * appropriate handlers, while logging timiing information.
 +     * 
 +     * @param jsonText
++     * @param statusCode
 +     */
-                     + jsonText);
++    private void handleJSONText(String jsonText, int statusCode) {
 +        final Date start = new Date();
 +        final ValueMap json;
 +        try {
 +            json = parseJSONResponse(jsonText);
 +        } catch (final Exception e) {
 +            endRequest();
 +            showCommunicationError(e.getMessage() + " - Original JSON-text:"
++                    + jsonText, statusCode);
 +            return;
 +        }
 +
 +        VConsole.log("JSON parsing took "
 +                + (new Date().getTime() - start.getTime()) + "ms");
 +        if (applicationRunning) {
 +            handleReceivedJSONMessage(start, jsonText, json);
 +        } else {
 +            applicationRunning = true;
 +            handleWhenCSSLoaded(jsonText, json);
 +        }
 +    }
 +
      /**
       * Sends an asynchronous UIDL request to the server using the given URI.
       * 
       * 
       * @param details
       *            Optional details for debugging.
 -     *            The http error code during the problematic request or -1 if
 -     *            error happened before response was received.
+      * @param statusCode
++     *            The status code returned for the request
++     * 
       */
-     protected void showCommunicationError(String details) {
+     protected void showCommunicationError(String details, int statusCode) {
 -        showAuthenticationError(details);
 +        VConsole.error("Communication error: " + details);
 +        ErrorMessage communicationError = configuration.getCommunicationError();
 +        showError(details, communicationError.getCaption(),
 +                communicationError.getMessage(), communicationError.getUrl());
      }
  
      /**