From 3a8b97e3697fb7df0c3f54f813e2018168ef05a7 Mon Sep 17 00:00:00 2001 From: Mika Murtojärvi Date: Wed, 17 Jun 2015 07:56:55 +0000 Subject: Revert "Prevent field from updating when removing text change listener. (#16270)" This reverts commit 4af793d06a0f4a6577aad13403ca7982c6fce224. Test ConverterThatEnforcesAFormatTest.checkElaborating is broken by this change. Change-Id: I8243f6a7bff6d7011d402bce4b614f7d2e4206fd --- server/src/com/vaadin/ui/AbstractTextField.java | 33 ++++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'server/src/com/vaadin') diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 14c135228c..93025ac0fd 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -126,22 +126,25 @@ public abstract class AbstractTextField extends AbstractField implements selectionPosition = -1; } - target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE, - getTextChangeEventMode().toString()); - target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT, - getTextChangeTimeout()); - if (lastKnownTextContent != null) { - /* - * The field has be repainted for some reason (e.g. caption, size, - * stylename), but the value has not been changed since the last - * text change event. Let the client side know about the value the - * server side knows. Client side may then ignore the actual value, - * depending on its state. - */ - target.addAttribute( - TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS, - true); + if (hasListeners(TextChangeEvent.class)) { + target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_EVENTMODE, + getTextChangeEventMode().toString()); + target.addAttribute(TextFieldConstants.ATTR_TEXTCHANGE_TIMEOUT, + getTextChangeTimeout()); + if (lastKnownTextContent != null) { + /* + * The field has be repainted for some reason (e.g. caption, + * size, stylename), but the value has not been changed since + * the last text change event. Let the client side know about + * the value the server side knows. Client side may then ignore + * the actual value, depending on its state. + */ + target.addAttribute( + TextFieldConstants.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS, + true); + } } + } @Override -- cgit v1.2.3 From f8aacf7c53d2e758e431588f44185b583fad8cb6 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sun, 14 Jun 2015 15:36:33 +0300 Subject: Allow beforeClientResponse to change hierarchy or dirtyness (#18268) Change-Id: I6a1ae23c1dd67f8889479a1069f260fa736bbd83 --- server/src/com/vaadin/server/ClientConnector.java | 4 -- .../vaadin/server/communication/UidlWriter.java | 38 +++++++++--- .../ChangeHierarchyBeforeResponse.java | 71 ++++++++++++++++++++++ .../ChangeHierarchyBeforeResponseTest.java | 43 +++++++++++++ 4 files changed, 143 insertions(+), 13 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponse.java create mode 100644 uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java (limited to 'server/src/com/vaadin') diff --git a/server/src/com/vaadin/server/ClientConnector.java b/server/src/com/vaadin/server/ClientConnector.java index b784aa5d35..63483bc254 100644 --- a/server/src/com/vaadin/server/ClientConnector.java +++ b/server/src/com/vaadin/server/ClientConnector.java @@ -256,10 +256,6 @@ public interface ClientConnector extends Connector { * client. Gives the connector an opportunity to set computed/dynamic state * values or to invoke last minute RPC methods depending on other component * features. - *

- * This method must not alter the component hierarchy in any way. Calling - * {@link #markAsDirty()} from this method will have no effect. - *

* * @param initial * true if the client-side connector will be created diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java index 3b2caba55b..00a65d3877 100644 --- a/server/src/com/vaadin/server/communication/UidlWriter.java +++ b/server/src/com/vaadin/server/communication/UidlWriter.java @@ -23,7 +23,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,22 +83,40 @@ public class UidlWriter implements Serializable { // to write out service.runPendingAccessTasks(session); - ArrayList dirtyVisibleConnectors = ui - .getConnectorTracker().getDirtyVisibleConnectors(); + Set processedConnectors = new HashSet(); + LegacyCommunicationManager manager = session.getCommunicationManager(); // Paints components ConnectorTracker uiConnectorTracker = ui.getConnectorTracker(); getLogger().log(Level.FINE, "* Creating response to client"); + while (true) { + ArrayList connectorsToProcess = new ArrayList(); + for (ClientConnector c : uiConnectorTracker.getDirtyConnectors()) { + if (!processedConnectors.contains(c) + && LegacyCommunicationManager + .isConnectorVisibleToClient(c)) { + connectorsToProcess.add(c); + } + } + + if (connectorsToProcess.isEmpty()) { + break; + } + + for (ClientConnector connector : connectorsToProcess) { + boolean initialized = uiConnectorTracker + .isClientSideInitialized(connector); + processedConnectors.add(connector); + + connector.beforeClientResponse(!initialized); + } + } + getLogger().log( Level.FINE, - "Found " + dirtyVisibleConnectors.size() + "Found " + processedConnectors.size() + " dirty connectors to paint"); - for (ClientConnector connector : dirtyVisibleConnectors) { - boolean initialized = uiConnectorTracker - .isClientSideInitialized(connector); - connector.beforeClientResponse(!initialized); - } uiConnectorTracker.setWritingResponse(true); try { @@ -292,7 +312,7 @@ public class UidlWriter implements Serializable { session.getDragAndDropService().printJSONResponse(writer); - for (ClientConnector connector : dirtyVisibleConnectors) { + for (ClientConnector connector : processedConnectors) { uiConnectorTracker.markClientSideInitialized(connector); } diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponse.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponse.java new file mode 100644 index 0000000000..e6daf8356c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponse.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.abstractcomponent; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.Label; + +public class ChangeHierarchyBeforeResponse extends AbstractTestUI { + private CssLayout layout = new CssLayout() { + @Override + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); + if (initial) { + addComponent(buttonToAdd); + removeComponent(labelToRemove); + } + } + }; + + private Button buttonToAdd = new Button("Added from beforeClientResponse", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + layout.addComponent(labelToRemove); + } + }) { + @Override + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); + setCaption("Add label to layout"); + } + }; + + private Label labelToRemove = new Label("Label to remove") { + int count = 0; + + @Override + public void beforeClientResponse(boolean initial) { + super.beforeClientResponse(initial); + if (initial) { + count++; + setValue("Initial count: " + count); + } + } + }; + + @Override + protected void setup(VaadinRequest request) { + layout.addComponent(labelToRemove); + + addComponent(layout); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java new file mode 100644 index 0000000000..485e218a68 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/ChangeHierarchyBeforeResponseTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.abstractcomponent; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ChangeHierarchyBeforeResponseTest extends SingleBrowserTest { + @Test + public void testHierarchyChangeBeforeResponse() { + openTestURL(); + + ButtonElement button = $(ButtonElement.class).first(); + + Assert.assertEquals( + "Button caption should change by its own beforeClientResponse", + "Add label to layout", button.getText()); + + button.click(); + + LabelElement label = $(LabelElement.class).all().get(1); + + Assert.assertEquals("Label should have been considered initial twice", + "Initial count: 2", label.getText()); + } +} -- cgit v1.2.3 From 024a2ab52e1ab5ac039c78f86c9c6fbf3a70f131 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Sun, 14 Jun 2015 15:46:14 +0300 Subject: Send beforeClientResponse exceptions to an error handler (#14214) Change-Id: Ib0cd9a402bbef0c7adb65bd8298a71b5521edd7c --- .../vaadin/server/LegacyCommunicationManager.java | 10 ++-- .../vaadin/server/communication/UidlWriter.java | 6 ++- .../tests/applicationservlet/SystemMessages.java | 7 ++- .../ResponseWritingErrorHandling.java | 61 ++++++++++++++++++++++ .../ResponseWritingErrorHandlingTest.java | 35 +++++++++++++ 5 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java create mode 100644 uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java (limited to 'server/src/com/vaadin') diff --git a/server/src/com/vaadin/server/LegacyCommunicationManager.java b/server/src/com/vaadin/server/LegacyCommunicationManager.java index fda5ad444f..e982cdf10a 100644 --- a/server/src/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/com/vaadin/server/LegacyCommunicationManager.java @@ -388,17 +388,15 @@ public class LegacyCommunicationManager implements Serializable { } /** - * Handles an exception that occurred when processing RPC calls or a file - * upload. + * Handles an exception related to a connector by invoking the appropriate + * error handler. * * @deprecated As of 7.1. See #11411. * - * @param ui - * The UI where the exception occured * @param throwable - * The exception + * the exception to handle * @param connector - * The Rpc target + * the connector that the exception is related to */ @Deprecated public void handleConnectorRelatedException(ClientConnector connector, diff --git a/server/src/com/vaadin/server/communication/UidlWriter.java b/server/src/com/vaadin/server/communication/UidlWriter.java index 00a65d3877..a4797e49aa 100644 --- a/server/src/com/vaadin/server/communication/UidlWriter.java +++ b/server/src/com/vaadin/server/communication/UidlWriter.java @@ -109,7 +109,11 @@ public class UidlWriter implements Serializable { .isClientSideInitialized(connector); processedConnectors.add(connector); - connector.beforeClientResponse(!initialized); + try { + connector.beforeClientResponse(!initialized); + } catch (RuntimeException e) { + manager.handleConnectorRelatedException(connector, e); + } } } diff --git a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java index 00547aa2d2..9912e660ef 100644 --- a/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java +++ b/uitest/src/com/vaadin/tests/applicationservlet/SystemMessages.java @@ -14,13 +14,15 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.NativeSelect; +import elemental.json.JsonObject; + public class SystemMessages extends AbstractTestUI { public class MyButton extends Button { private boolean fail = false; @Override - public void beforeClientResponse(boolean initial) { + public JsonObject encodeState() { // Set the error message to contain the current locale. VaadinService.getCurrentRequest().setAttribute( ApplicationRunnerServlet.CUSTOM_SYSTEM_MESSAGES_PROPERTY, @@ -30,9 +32,10 @@ public class SystemMessages extends AbstractTestUI { return "MessagesInfo locale: " + getLocale(); } }); - super.beforeClientResponse(initial); if (fail) { throw new RuntimeException("Failed on purpose"); + } else { + return super.encodeState(); } } } diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java new file mode 100644 index 0000000000..23be0f62b4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandling.java @@ -0,0 +1,61 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.abstractcomponent; + +import com.vaadin.server.ErrorHandler; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; + +public class ResponseWritingErrorHandling extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + ErrorHandler errorHandler = new ErrorHandler() { + @Override + public void error(com.vaadin.server.ErrorEvent event) { + String message = event.getThrowable().getMessage(); + log(message); + } + }; + + Button button = new Button("Throw in beforeClientResponse") { + private boolean throwInBeforeClientResponse = false; + { + addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + throwInBeforeClientResponse = true; + // Make sure beforeClientResponse is called + markAsDirty(); + } + }); + } + + @Override + public void beforeClientResponse(boolean initial) { + if (throwInBeforeClientResponse) { + throwInBeforeClientResponse = false; + throw new RuntimeException("Button.beforeClientResponse"); + } + } + }; + button.setErrorHandler(errorHandler); + + addComponent(button); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java b/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java new file mode 100644 index 0000000000..7b939a5627 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/abstractcomponent/ResponseWritingErrorHandlingTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.abstractcomponent; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ResponseWritingErrorHandlingTest extends SingleBrowserTest { + + @Test + public void testExceptionInBeforeClientResponse() { + openTestURL(); + + $(ButtonElement.class).first().click(); + + Assert.assertEquals("Message should be logged by error handler", + "1. Button.beforeClientResponse", getLogRow(0)); + } +} -- cgit v1.2.3 From 1eaa302928c0a653885cfdaa552806f899f8ed60 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Wed, 17 Jun 2015 20:24:02 +0300 Subject: Take Window special case into account for invalid layouts (#17598) Change-Id: If736e0d35376f90dee33d93588351ef726a4635f --- server/src/com/vaadin/server/ComponentSizeValidator.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'server/src/com/vaadin') diff --git a/server/src/com/vaadin/server/ComponentSizeValidator.java b/server/src/com/vaadin/server/ComponentSizeValidator.java index 1fbd840932..71023782ef 100644 --- a/server/src/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/com/vaadin/server/ComponentSizeValidator.java @@ -598,6 +598,12 @@ public class ComponentSizeValidator implements Serializable { if (parent == null) { return false; } else if (parent.getWidth() < 0) { + if (parent instanceof Window) { + // Window has some weird haxxors to support 100% children when + // window is -1 + return false; + } + return true; } else if (parent.getWidthUnits() == Unit.PERCENTAGE) { return isEffectiveUndefinedWidth(parent.getParent()); @@ -615,6 +621,12 @@ public class ComponentSizeValidator implements Serializable { if (parent == null) { return false; } else if (parent.getHeight() < 0) { + if (parent instanceof Window) { + // Window has some weird haxxors to support 100% children when + // window is -1 + return false; + } + return true; } else if (parent.getHeightUnits() == Unit.PERCENTAGE) { return isEffectiveUndefinedHeight(parent.getParent()); -- cgit v1.2.3 From 050dd3659768da39260e7838bc57070c1361c1ac Mon Sep 17 00:00:00 2001 From: Steven Spungin Date: Fri, 19 Jun 2015 23:39:23 -0400 Subject: Fix spelling Change-Id: I7fb13c520c8ff402971214022d44be0db2b9c3ea --- client/src/com/vaadin/client/ui/VScrollTable.java | 4 ++-- server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'server/src/com/vaadin') diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index d3958a2f00..0ef0cb6949 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -303,7 +303,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, */ private double cache_rate = CACHE_RATE_DEFAULT; /** - * fraction of pageLenght which can be scrolled without making new request + * fraction of pageLength which can be scrolled without making new request */ private double cache_react_rate = 0.75 * cache_rate; @@ -1443,7 +1443,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, if (uidl.hasAttribute("pagelength")) { pageLength = uidl.getIntAttribute("pagelength"); } else { - // pagelenght is "0" meaning scrolling is turned off + // pagelength is "0" meaning scrolling is turned off pageLength = totalRows; } diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index f07b7ecc58..86e9069e90 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -1279,7 +1279,7 @@ public class SQLContainer implements Container, Container.Filterable, } /** - * Fetches a page from the data source based on the values of pageLenght and + * Fetches a page from the data source based on the values of pageLength and * currentOffset. Also updates the set of primary keys, used in * identification of RowItems. */ -- cgit v1.2.3 From 122fccfe01f8f1aca922d861b44853b09fe8f603 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Mon, 18 May 2015 15:10:30 +0300 Subject: Write true as attribute="" (#17519) Change-Id: I49287cc38605abb75059cb553e3baed2a8359067 --- server/src/com/vaadin/ui/AbstractComponent.java | 12 ++--- .../com/vaadin/ui/declarative/DesignFormatter.java | 6 ++- .../components/menubar/MenuBarDeclarativeTest.java | 21 +++++---- .../design/AbstractComponentSetResponsiveTest.java | 2 +- .../vaadin/tests/design/DesignFormatterTest.java | 2 +- .../component/DeclarativeMarginTestBase.java | 10 ++--- .../AbstractComponentDeclarativeTest.java | 16 +++---- .../AbstractFieldDeclarativeTest.java | 8 ++-- .../AbstractSelectDeclarativeTest.java | 8 ++-- .../OptionGroupDeclarativeTests.java | 2 +- .../AbstractSplitPanelDeclarativeTest.java | 2 +- .../AbstractTextFieldDeclarativeTest.java | 2 +- .../component/audio/AudioDeclarativeTest.java | 2 +- .../component/audio/VideoDeclarativeTest.java | 2 +- .../checkbox/CheckboxDeclarativeTest.java | 2 +- .../AbstractColorPickerDeclarativeTest.java | 4 +- .../datefield/DateFieldDeclarativeTest.java | 2 +- .../declarative/GridColumnDeclarativeTest.java | 8 ++-- .../declarative/GridDeclarativeAttributeTest.java | 4 +- .../GridHeaderFooterDeclarativeTest.java | 52 +++++++++++----------- .../declarative/GridInlineDataDeclarativeTest.java | 14 +++--- .../popupview/PopupViewDeclarativeTest.java | 2 +- .../progressbar/ProgressBarDeclarativeTest.java | 2 +- .../richtextarea/RichTextAreaDeclarativeTest.java | 2 +- .../component/table/TableDeclarativeTest.java | 8 ++-- .../tabsheet/TabSheetDeclarativeTest.java | 8 ++-- .../treetable/TreeTableDeclarativeTest.java | 2 +- .../component/window/WindowDeclarativeTest.java | 4 +- 28 files changed, 105 insertions(+), 104 deletions(-) (limited to 'server/src/com/vaadin') diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index 18c3509af7..f499cb1fec 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -1170,16 +1170,16 @@ public abstract class AbstractComponent extends AbstractClientConnector // first try the full shorthands if (widthFull && heightFull) { - attributes.put("size-full", "true"); + attributes.put("size-full", ""); } else if (widthAuto && heightAuto) { - attributes.put("size-auto", "true"); + attributes.put("size-auto", ""); } else { // handle width if (!hasEqualWidth(defaultInstance)) { if (widthFull) { - attributes.put("width-full", "true"); + attributes.put("width-full", ""); } else if (widthAuto) { - attributes.put("width-auto", "true"); + attributes.put("width-auto", ""); } else { String widthString = DesignAttributeHandler.getFormatter() .format(getWidth()) + getWidthUnits().getSymbol(); @@ -1190,9 +1190,9 @@ public abstract class AbstractComponent extends AbstractClientConnector if (!hasEqualHeight(defaultInstance)) { // handle height if (heightFull) { - attributes.put("height-full", "true"); + attributes.put("height-full", ""); } else if (heightAuto) { - attributes.put("height-auto", "true"); + attributes.put("height-auto", ""); } else { String heightString = DesignAttributeHandler.getFormatter() .format(getHeight()) + getHeightUnits().getSymbol(); diff --git a/server/src/com/vaadin/ui/declarative/DesignFormatter.java b/server/src/com/vaadin/ui/declarative/DesignFormatter.java index b1d2520631..73c45caed4 100644 --- a/server/src/com/vaadin/ui/declarative/DesignFormatter.java +++ b/server/src/com/vaadin/ui/declarative/DesignFormatter.java @@ -94,7 +94,11 @@ public class DesignFormatter implements Serializable { public String convertToPresentation(Boolean value, Class targetType, Locale locale) throws Converter.ConversionException { - return String.valueOf(value.booleanValue()); + if (value.booleanValue()) { + return ""; + } else { + return "false"; + } } @Override diff --git a/server/tests/src/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java b/server/tests/src/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java index 3bc1ebfbf9..d058ae1dcd 100644 --- a/server/tests/src/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/components/menubar/MenuBarDeclarativeTest.java @@ -38,10 +38,10 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase { @Test // #16328 public void testReadWrite() throws IOException { - String design = "" - + "Save" + String design = "" + + "Save" + "Open" - + "Close" + + "Close" + "Help" + "About" + "SubItem" @@ -69,19 +69,19 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase { @Test // #16328 public void testTicketSpec1() throws IOException { - String design = " " + String design = " " + "File" + "Save" + "Open" - + "" - + "Exit" + + "" + + "Exit" + "Not for everybody" + "" + "Other" + "Sub" - + "Option 1 - no html" - + "Option 2" - + "Option 3" // + + "Option 1 - no html" + + "Option 2" + + "Option 3" // + "" // + "" // + "foo" @@ -124,8 +124,7 @@ public class MenuBarDeclarativeTest extends DeclarativeTestBase { + "File" + "Save" + "Open" - + "" - + "Exit" // + + "" + "Exit" // + ""; MenuBar menuBar = new MenuBar(); menuBar.setHtmlContentAllowed(true); diff --git a/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java index 83b3e577dc..1119301c55 100644 --- a/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java +++ b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java @@ -29,7 +29,7 @@ public class AbstractComponentSetResponsiveTest extends label.setContentMode(ContentMode.HTML); label.setResponsive(true); - String design = ""; + String design = ""; testWrite(design, label); testRead(design, label); diff --git a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java index 00af20ea8c..acee3e2ca8 100644 --- a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java +++ b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java @@ -78,7 +78,7 @@ public class DesignFormatterTest { @Test public void testBoolean() { - assertEquals("true", formatter.format(true)); + assertEquals("", formatter.format(true)); assertEquals("false", formatter.format(false)); assertEquals(true, formatter.parse("true", boolean.class)); diff --git a/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java b/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java index 9fcb64acca..42715e52ae 100644 --- a/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java +++ b/server/tests/src/com/vaadin/tests/server/component/DeclarativeMarginTestBase.java @@ -52,19 +52,19 @@ public abstract class DeclarativeMarginTestBase"; diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java index 4f45168a32..71021a06e1 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/AbstractComponentDeclarativeTest.java @@ -71,7 +71,7 @@ public class AbstractComponentDeclarativeTest extends public void testProperties() { String design = "test-error\" immediate=\"true\"/>"; + + "error=\"
test-error
\" immediate=\"\"/>"; component.setId("testId"); component.setPrimaryStyleName("test-style"); component.setCaption("test-caption"); @@ -139,7 +139,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testSizeFull() { - String design = ""; + String design = ""; component.setSizeFull(); testRead(design, component); testWrite(design, component); @@ -147,7 +147,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testSizeAuto() { - String design = ""; + String design = ""; component.setSizeUndefined(); testRead(design, component); testWrite(design, component); @@ -155,7 +155,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testHeightFull() { - String design = ""; + String design = ""; component.setHeight("100%"); component.setWidth("20px"); testRead(design, component); @@ -164,7 +164,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testHeightAuto() { - String design = ""; + String design = ""; // we need to have default height of 100% -> use split panel AbstractComponent component = new HorizontalSplitPanel(); component.setHeight(null); @@ -175,7 +175,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testWidthFull() { - String design = "Foo"; + String design = "Foo"; AbstractComponent component = new Button(); component.setCaptionAsHtml(true); component.setCaption("Foo"); @@ -187,7 +187,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testWidthAuto() { - String design = ""; + String design = ""; component.setCaptionAsHtml(false); component.setHeight("20px"); component.setWidth(null); @@ -197,7 +197,7 @@ public class AbstractComponentDeclarativeTest extends @Test public void testResponsive() { - String design = ""; + String design = ""; Responsive.makeResponsive(component); testRead(design, component); testWrite(design, component); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java index 55231e5494..b4afde5923 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java @@ -33,9 +33,9 @@ public class AbstractFieldDeclarativeTest extends @Test public void testPlainText() { - String design = ""; + String design = ""; AbstractField tf = new TextField(); tf.setBuffered(true); tf.setBuffered(true); @@ -51,7 +51,7 @@ public class AbstractFieldDeclarativeTest extends testWrite(design, tf); // Test with readonly=false - design = design.replace("readonly='true'", ""); + design = design.replace("readonly=''", ""); tf.setReadOnly(false); testRead(design, tf); testWrite(design, tf); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java index b3867a7a3a..b294ffad72 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/AbstractSelectDeclarativeTest.java @@ -42,7 +42,7 @@ public class AbstractSelectDeclarativeTest extends DeclarativeTestBase { public String getDesignSingleSelectNewItemsAllowed() { - return ""; } @@ -57,7 +57,7 @@ public class AbstractSelectDeclarativeTest extends } public String getDesignMultiSelect() { - return ""; + return ""; } public AbstractSelect getExpectedMultiSelect() { @@ -210,7 +210,7 @@ public class AbstractSelectDeclarativeTest extends attributes.put("item-caption-mode", "property"); attributes.put("item-caption-property-id", "name"); attributes.put("item-icon-property-id", "icon"); - attributes.put("null-selection-allowed", "true"); + attributes.put("null-selection-allowed", ""); attributes.put("null-selection-item-id", "No items selected"); return new Element(Tag.valueOf("v-combo-box"), "", attributes); } @@ -231,7 +231,7 @@ public class AbstractSelectDeclarativeTest extends assertEquals("Wrong caption for the combo box.", "A combo box", e.attr("caption")); Assert.assertTrue("Adding new items should be allowed.", - "true".equals(e.attr("new-items-allowed"))); + "".equals(e.attr("new-items-allowed"))); assertEquals("Wrong item caption mode.", "icon_only", e.attr("item-caption-mode")); assertEquals("Wrong item icon property id.", "icon", diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java b/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java index 4d75e0b59f..efcdc3e997 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractselect/OptionGroupDeclarativeTests.java @@ -111,7 +111,7 @@ public class OptionGroupDeclarativeTests extends //@formatter:off String expected = - "" + "" + "" + "" + "" diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java index 2d6db6d19a..11d97d191b 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstractsplitpanel/AbstractSplitPanelDeclarativeTest.java @@ -38,7 +38,7 @@ public class AbstractSplitPanelDeclarativeTest extends @Test public void testWithBothChildren() { String design = " " + ""; AbstractSplitPanel sp = new HorizontalSplitPanel(); diff --git a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldDeclarativeTest.java index a3594b7159..b8e570bc89 100644 --- a/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/abstracttextfield/AbstractTextFieldDeclarativeTest.java @@ -34,7 +34,7 @@ public class AbstractTextFieldDeclarativeTest extends @Test public void testAttributes() { String design = ""; AbstractTextField tf = new TextField(); diff --git a/server/tests/src/com/vaadin/tests/server/component/audio/AudioDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/audio/AudioDeclarativeTest.java index 4390499c4e..ec2b5241f3 100644 --- a/server/tests/src/com/vaadin/tests/server/component/audio/AudioDeclarativeTest.java +++ b/server/tests/src/com/vaadin/tests/server/component/audio/AudioDeclarativeTest.java @@ -43,7 +43,7 @@ public class AudioDeclarativeTest extends DeclarativeTestBase