aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-06-14 13:11:37 +0000
committerJohannes Dahlström <johannes.dahlstrom@vaadin.com>2012-06-14 13:11:37 +0000
commit0abcf847a27cff763f3dfea6aeec04b5aeb633d4 (patch)
treeb56e598709d2866019660079652153b1eb54b84f
parent835c03b8633454861b491dd6053a990579e19de8 (diff)
downloadvaadin-framework-0abcf847a27cff763f3dfea6aeec04b5aeb633d4.tar.gz
vaadin-framework-0abcf847a27cff763f3dfea6aeec04b5aeb633d4.zip
#8852 Applied Sami's patch with minor changes to comments and the test
svn changeset:23938/svn branch:6.8
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VForm.java5
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java24
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html57
-rw-r--r--tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java58
4 files changed, 135 insertions, 9 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VForm.java b/src/com/vaadin/terminal/gwt/client/ui/VForm.java
index c0a6e5b275..546f90a39b 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VForm.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VForm.java
@@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui;
import java.util.Set;
-import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.event.shared.HandlerRegistration;
@@ -39,7 +38,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler {
private Container lo;
private Element legend = DOM.createLegend();
private Element caption = DOM.createSpan();
- private Element errorIndicatorElement = DOM.createDiv();
private Element desc = DOM.createDiv();
private Icon icon;
private VErrorMessage errorMessage = new VErrorMessage();
@@ -70,9 +68,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler {
setStyleName(CLASSNAME);
fieldSet.appendChild(legend);
legend.appendChild(caption);
- errorIndicatorElement.setClassName("v-errorindicator");
- errorIndicatorElement.getStyle().setDisplay(Display.NONE);
- errorIndicatorElement.setInnerText(" "); // needed for IE
desc.setClassName("v-form-description");
fieldSet.appendChild(desc); // Adding description for initial padding
// measurements, removed later if no
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index 2355a9c65a..2384ee7ddd 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -390,6 +390,17 @@ public class VWindow extends VOverlay implements Container,
layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth");
layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight");
+ // Ticket #8852: We have to override min height if height of both window
+ // and layout have undefined height. 0 is used to as undefined value and
+ // replacing it with 30 will lead to calculation errors (as browser
+ // takes care of height modifications).
+ if (dynamicHeight && !layoutRelativeHeight
+ && !childUidl.hasAttribute("height")) {
+ renderSpace.setHeight(0);
+ } else if (renderSpace.getHeight() < MIN_CONTENT_AREA_HEIGHT) {
+ renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+ }
+
if (dynamicWidth && layoutRelativeWidth) {
/*
* Relative layout width, fix window width before rendering (width
@@ -1161,12 +1172,17 @@ public class VWindow extends VOverlay implements Container,
return;
}
if (height == null || "".equals(height)) {
+
getElement().getStyle().clearHeight();
contentPanel.getElement().getStyle().clearHeight();
- // Reset to default, the exact value does not actually
- // matter as an undefined-height parent should not have
- // a relative-height child anyway.
- renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+
+ // If content and window both have undefined height do not set min
+ // height to render space
+ if (renderSpace.getHeight() != 0 || !dynamicHeight
+ || layoutRelativeHeight) {
+ renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT);
+ }
+
} else {
getElement().getStyle().setProperty("height", height);
int contentHeight = getElement().getOffsetHeight()
diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html
new file mode 100644
index 0000000000..a3b56cd12a
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>UndefinedHeightSubWindowAndContent</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">UndefinedHeightSubWindowAndContent</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.window.UndefinedHeightSubWindowAndContent?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>52,11</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>invalid</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>form_full_width_1_error</td>
+</tr>
+<tr>
+ <td>enterCharacter</td>
+ <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>valid</td>
+</tr>
+<tr>
+ <td>pressSpecialKey</td>
+ <td>vaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]</td>
+ <td>enter</td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>form_full_width_2_valid</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java
new file mode 100644
index 0000000000..ed259b2f4c
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java
@@ -0,0 +1,58 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.data.Validator;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class UndefinedHeightSubWindowAndContent extends TestBase {
+
+ @Override
+ protected void setup() {
+ Window subWindow = new Window("No scrollbars!");
+ subWindow.setWidth("300px");
+ subWindow.center();
+ subWindow.setModal(true);
+ VerticalLayout layout = new VerticalLayout();
+ layout.setWidth("100%");
+ subWindow.setContent(layout);
+
+ final Form form = new Form();
+ form.setImmediate(true);
+ form.setValidationVisible(true);
+ form.setCaption("This is a form");
+ form.setDescription("How do you do?");
+ final TextField field1 = new TextField("Write here");
+ field1.setImmediate(true);
+ field1.addValidator(new Validator() {
+
+ public void validate(Object value) throws InvalidValueException {
+ if (!isValid(value)) {
+ throw new InvalidValueException("FAIL!");
+ }
+ }
+
+ public boolean isValid(Object value) {
+ return field1.getValue().equals("valid");
+ }
+ });
+ form.addField("Field 1", field1);
+ layout.addComponent(form);
+
+ getMainWindow().addWindow(subWindow);
+ subWindow.bringToFront();
+ }
+
+ @Override
+ protected String getDescription() {
+ return "When both window and its content have undefined height, window must not reserve space for a scroll bar when it is not needed.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 8852;
+ }
+
+}