From: Artur Signell Date: Tue, 8 Sep 2009 13:26:25 +0000 (+0000) Subject: Test case and fix for #3248 - PopupView should allow null minimized value and lazily... X-Git-Tag: 6.7.0.beta1~2492 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=45892c57a8326c6ceae321d09293105c956b5077;p=vaadin-framework.git Test case and fix for #3248 - PopupView should allow null minimized value and lazily initialize component svn changeset:8714/svn branch:6.1 --- diff --git a/src/com/vaadin/tests/components/popupview/PopupViewNullValues.java b/src/com/vaadin/tests/components/popupview/PopupViewNullValues.java new file mode 100644 index 0000000000..30fa028c40 --- /dev/null +++ b/src/com/vaadin/tests/components/popupview/PopupViewNullValues.java @@ -0,0 +1,103 @@ +package com.vaadin.tests.components.popupview; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.PopupView; +import com.vaadin.ui.TextField; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.Window.Notification; + +public class PopupViewNullValues extends TestBase { + + private PopupView pv[] = new PopupView[4]; + private Button b[] = new Button[4]; + + @Override + protected void setup() { + try { + pv[0] = new PopupView("Popupview 1 - no component", null); + addComponent(pv[0]); + b[0] = new Button("Open popupview 1", new ClickListener() { + + public void buttonClick(ClickEvent event) { + pv[0].setPopupVisible(true); + } + + }); + } catch (Exception e) { + getMainWindow() + .showNotification( + "Error, 'null content' should not throw an exception at this point", + Notification.TYPE_ERROR_MESSAGE); + } + + try { + pv[1] = new PopupView(null, new TextField( + "Empty html, contains component")); + addComponent(pv[1]); + b[1] = new Button("Open popupview 2", new ClickListener() { + + public void buttonClick(ClickEvent event) { + pv[1].setPopupVisible(true); + } + + }); + } catch (Exception e) { + getMainWindow() + .showNotification( + "Error, 'null html', should not throw an exception at this point", + Notification.TYPE_ERROR_MESSAGE); + } + + try { + pv[2] = new PopupView(null, null); + addComponent(pv[2]); + b[2] = new Button("Open popupview 3", new ClickListener() { + + public void buttonClick(ClickEvent event) { + pv[2].setPopupVisible(true); + } + + }); + } catch (Exception e) { + getMainWindow() + .showNotification( + "Error, 'null html, null content', should not throw an exception at this point", + Notification.TYPE_ERROR_MESSAGE); + } + try { + pv[3] = new PopupView("Popupview 4 - has component", new TextField( + "This is the content of popupview 4")); + addComponent(pv[3]); + b[3] = new Button("Open popupview 4", new ClickListener() { + + public void buttonClick(ClickEvent event) { + pv[3].setPopupVisible(true); + } + + }); + } catch (Exception e) { + getMainWindow() + .showNotification( + "Error, 'null html, null content', should not throw an exception at this point", + Notification.TYPE_ERROR_MESSAGE); + } + + addComponent(b[0]); + addComponent(b[1]); + addComponent(b[2]); + addComponent(b[3]); + } + + @Override + protected String getDescription() { + 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."; + } + + @Override + protected Integer getTicketNumber() { + return 3248; + } + +} diff --git a/src/com/vaadin/ui/PopupView.java b/src/com/vaadin/ui/PopupView.java index 4fa89a7eb5..f2d6259c75 100644 --- a/src/com/vaadin/ui/PopupView.java +++ b/src/com/vaadin/ui/PopupView.java @@ -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