]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added missing setters for communication error message, fixes #2521. Also fixed a...
authorMarc Englund <marc.englund@itmill.com>
Fri, 30 Jan 2009 06:57:09 +0000 (06:57 +0000)
committerMarc Englund <marc.englund@itmill.com>
Fri, 30 Jan 2009 06:57:09 +0000 (06:57 +0000)
svn changeset:6679/svn branch:trunk

src/com/itmill/toolkit/Application.java
src/com/itmill/toolkit/terminal/gwt/client/ApplicationConnection.java

index 866a9ced51a19d0b3ad19c4b209414391acbefe1..ad51911ed78f4002d16abe2f4335b71acb075dc7 100644 (file)
@@ -1422,6 +1422,52 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener
             this.sessionExpiredMessage = sessionExpiredMessage;
         }
 
+        /**
+         * Sets the URL to go to when there is a communication error.
+         * 
+         * @param communicationErrorURL
+         *            the URL to go to, or null to reload current
+         */
+        public void setCommunicationErrorURL(String communicationErrorURL) {
+            this.communicationErrorURL = communicationErrorURL;
+        }
+
+        /**
+         * Enables or disables the notification. If disabled, the set URL (or
+         * current) is loaded directly.
+         * 
+         * @param communicationErrorNotificationEnabled
+         *            true = enabled, false = disabled
+         */
+        public void setCommunicationErrorNotificationEnabled(
+                boolean communicationErrorNotificationEnabled) {
+            this.communicationErrorNotificationEnabled = communicationErrorNotificationEnabled;
+        }
+
+        /**
+         * Sets the caption of the notification. Set to null for no caption. If
+         * both caption and message is null, the notification is disabled;
+         * 
+         * @param communicationErrorCaption
+         *            the caption
+         */
+        public void setCommunicationErrorCaption(
+                String communicationErrorCaption) {
+            this.communicationErrorCaption = communicationErrorCaption;
+        }
+
+        /**
+         * Sets the message of the notification. Set to null for no message. If
+         * both caption and message is null, the notification is disabled;
+         * 
+         * @param communicationErrorMessage
+         *            the message
+         */
+        public void setCommunicationErrorMessage(
+                String communicationErrorMessage) {
+            this.communicationErrorMessage = communicationErrorMessage;
+        }
+
         /**
          * Sets the URL to go to when an internal error occurs.
          * 
index 47e1f06d52c1a2690f0edcdac1ca008b31ce1eea..2959aa74cdd66639b7a5b049725240a55126b9f3 100755 (executable)
@@ -424,10 +424,16 @@ public class ApplicationConnection {
             html += "<p>" + configuration.getCommunicationErrorMessage()
                     + "</p>";
         }
-        INotification n = new INotification(1000 * 60 * 45);
-        n.addEventListener(new NotificationRedirect(configuration
-                .getCommunicationErrorUrl()));
-        n.show(html, INotification.CENTERED_TOP, INotification.STYLE_SYSTEM);
+        if (html.length() > 0) {
+            INotification n = new INotification(1000 * 60 * 45);
+            n.addEventListener(new NotificationRedirect(configuration
+                    .getCommunicationErrorUrl()));
+            n
+                    .show(html, INotification.CENTERED_TOP,
+                            INotification.STYLE_SYSTEM);
+        } else {
+            redirect(configuration.getCommunicationErrorUrl());
+        }
     }
 
     private native void syncSendForce(JavaScriptObject xmlHttpRequest,