summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-09-08 13:26:25 +0000
committerArtur Signell <artur.signell@itmill.com>2009-09-08 13:26:25 +0000
commit45892c57a8326c6ceae321d09293105c956b5077 (patch)
tree0c25a115ee1878eab01fad17d23fc9d4fd47177c /src
parent9016a923c4320004076230ff28901c39d3951738 (diff)
downloadvaadin-framework-45892c57a8326c6ceae321d09293105c956b5077.tar.gz
vaadin-framework-45892c57a8326c6ceae321d09293105c956b5077.zip
Test case and fix for #3248 - PopupView should allow null minimized value and lazily initialize component
svn changeset:8714/svn branch:6.1
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/tests/components/popupview/PopupViewNullValues.java103
-rw-r--r--src/com/vaadin/ui/PopupView.java12
2 files changed, 107 insertions, 8 deletions
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