]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test case and fix for #3248 - PopupView should allow null minimized value and lazily...
authorArtur Signell <artur.signell@itmill.com>
Tue, 8 Sep 2009 13:26:25 +0000 (13:26 +0000)
committerArtur Signell <artur.signell@itmill.com>
Tue, 8 Sep 2009 13:26:25 +0000 (13:26 +0000)
svn changeset:8714/svn branch:6.1

src/com/vaadin/tests/components/popupview/PopupViewNullValues.java [new file with mode: 0644]
src/com/vaadin/ui/PopupView.java

diff --git a/src/com/vaadin/tests/components/popupview/PopupViewNullValues.java b/src/com/vaadin/tests/components/popupview/PopupViewNullValues.java
new file mode 100644 (file)
index 0000000..30fa028
--- /dev/null
@@ -0,0 +1,103 @@
+package com.vaadin.tests.components.popupview;\r
+\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Button;\r
+import com.vaadin.ui.PopupView;\r
+import com.vaadin.ui.TextField;\r
+import com.vaadin.ui.Button.ClickEvent;\r
+import com.vaadin.ui.Button.ClickListener;\r
+import com.vaadin.ui.Window.Notification;\r
+\r
+public class PopupViewNullValues extends TestBase {\r
+\r
+    private PopupView pv[] = new PopupView[4];\r
+    private Button b[] = new Button[4];\r
+\r
+    @Override\r
+    protected void setup() {\r
+        try {\r
+            pv[0] = new PopupView("Popupview 1 - no component", null);\r
+            addComponent(pv[0]);\r
+            b[0] = new Button("Open popupview 1", new ClickListener() {\r
+\r
+                public void buttonClick(ClickEvent event) {\r
+                    pv[0].setPopupVisible(true);\r
+                }\r
+\r
+            });\r
+        } catch (Exception e) {\r
+            getMainWindow()\r
+                    .showNotification(\r
+                            "Error, 'null content' should not throw an exception at this point",\r
+                            Notification.TYPE_ERROR_MESSAGE);\r
+        }\r
+\r
+        try {\r
+            pv[1] = new PopupView(null, new TextField(\r
+                    "Empty html, contains component"));\r
+            addComponent(pv[1]);\r
+            b[1] = new Button("Open popupview 2", new ClickListener() {\r
+\r
+                public void buttonClick(ClickEvent event) {\r
+                    pv[1].setPopupVisible(true);\r
+                }\r
+\r
+            });\r
+        } catch (Exception e) {\r
+            getMainWindow()\r
+                    .showNotification(\r
+                            "Error, 'null html', should not throw an exception at this point",\r
+                            Notification.TYPE_ERROR_MESSAGE);\r
+        }\r
+\r
+        try {\r
+            pv[2] = new PopupView(null, null);\r
+            addComponent(pv[2]);\r
+            b[2] = new Button("Open popupview 3", new ClickListener() {\r
+\r
+                public void buttonClick(ClickEvent event) {\r
+                    pv[2].setPopupVisible(true);\r
+                }\r
+\r
+            });\r
+        } catch (Exception e) {\r
+            getMainWindow()\r
+                    .showNotification(\r
+                            "Error, 'null html, null content', should not throw an exception at this point",\r
+                            Notification.TYPE_ERROR_MESSAGE);\r
+        }\r
+        try {\r
+            pv[3] = new PopupView("Popupview 4 - has component", new TextField(\r
+                    "This is the content of popupview 4"));\r
+            addComponent(pv[3]);\r
+            b[3] = new Button("Open popupview 4", new ClickListener() {\r
+\r
+                public void buttonClick(ClickEvent event) {\r
+                    pv[3].setPopupVisible(true);\r
+                }\r
+\r
+            });\r
+        } catch (Exception e) {\r
+            getMainWindow()\r
+                    .showNotification(\r
+                            "Error, 'null html, null content', should not throw an exception at this point",\r
+                            Notification.TYPE_ERROR_MESSAGE);\r
+        }\r
+\r
+        addComponent(b[0]);\r
+        addComponent(b[1]);\r
+        addComponent(b[2]);\r
+        addComponent(b[3]);\r
+    }\r
+\r
+    @Override\r
+    protected String getDescription() {\r
+        return "This test case contains 3 popupviews. Only the second and the forth popup views have non-null components and can be opened. 1 and 3 will produce an exception if you try to open them.";\r
+    }\r
+\r
+    @Override\r
+    protected Integer getTicketNumber() {\r
+        return 3248;\r
+    }\r
+\r
+}\r
index 4fa89a7eb520d1dd96f525f067622192a0e3071c..f2d6259c75bfda71ee9d815a3df78630824d0a96 100644 (file)
@@ -87,12 +87,9 @@ public class PopupView extends AbstractComponentContainer {
      */
     public void setContent(PopupView.Content newContent)
             throws IllegalArgumentException {
-        if (newContent == null || newContent.getMinimizedValueAsHTML() == null
-                || newContent.getPopupComponent() == null) {
-            throw new IllegalArgumentException(
-                    "Content object is or contains null");
+        if (newContent == null) {
+            throw new IllegalArgumentException("Content must not be null");
         }
-
         content = newContent;
         requestRepaint();
     }
@@ -297,10 +294,9 @@ public class PopupView extends AbstractComponentContainer {
 
         String html = content.getMinimizedValueAsHTML();
         if (html == null) {
-            throw new PaintException(
-                    "Recieved null when trying to paint minimized value.");
+            html = "";
         }
-        target.addAttribute("html", content.getMinimizedValueAsHTML());
+        target.addAttribute("html", html);
         target.addAttribute("hideOnMouseOut", hideOnMouseOut);
 
         // Only paint component to client if we know that the popup is showing