summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2017-03-06 15:46:39 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-07 12:36:54 +0200
commit5081392bfdf6b74915952a64d1070255f7268457 (patch)
tree844b30924068616ea350da97a27966d16d5c9380
parent7646cfa49baeb4029b4af74b3da97b61b3363215 (diff)
downloadvaadin-framework-5081392bfdf6b74915952a64d1070255f7268457.tar.gz
vaadin-framework-5081392bfdf6b74915952a64d1070255f7268457.zip
Revert html content through shared state for OptionGroup
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java18
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java5
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java15
-rw-r--r--compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java2
-rw-r--r--compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupState.java4
5 files changed, 23 insertions, 21 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
index b67edfe93c..ee9048d4c2 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
@@ -87,7 +87,8 @@ public class VOptionGroup extends VOptionGroupBase
*/
private boolean blurOccured = false;
- private boolean htmlContentAllowed = false;
+ /** For internal use only. May be removed or replaced in the future. */
+ public boolean htmlContentAllowed = false;
private boolean wasHtmlContentAllowed = false;
private boolean wasMultiselect = false;
@@ -137,7 +138,7 @@ public class VOptionGroup extends VOptionGroupBase
final UIDL opUidl = (UIDL) it.next();
String itemHtml = opUidl.getStringAttribute("caption");
- if (!isHtmlContentAllowed()) {
+ if (!htmlContentAllowed) {
itemHtml = WidgetUtil.escapeHTML(itemHtml);
}
@@ -152,8 +153,7 @@ public class VOptionGroup extends VOptionGroupBase
// Need to recreate object if isMultiselect is changed (#10451)
// OR if htmlContentAllowed changed due to Safari 5 issue
- if ((op == null)
- || (isHtmlContentAllowed() != wasHtmlContentAllowed)
+ if ((op == null) || (htmlContentAllowed != wasHtmlContentAllowed)
|| (isMultiselect() != wasMultiselect)) {
// Create a new element
if (isMultiselect()) {
@@ -195,7 +195,7 @@ public class VOptionGroup extends VOptionGroupBase
}
}
- wasHtmlContentAllowed = isHtmlContentAllowed();
+ wasHtmlContentAllowed = htmlContentAllowed;
wasMultiselect = isMultiselect();
}
@@ -311,12 +311,4 @@ public class VOptionGroup extends VOptionGroupBase
});
}
}
-
- public boolean isHtmlContentAllowed() {
- return htmlContentAllowed;
- }
-
- public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- this.htmlContentAllowed = htmlContentAllowed;
- }
}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java
index dbed217598..097f38f4d1 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java
@@ -26,6 +26,7 @@ import com.vaadin.client.UIDL;
import com.vaadin.shared.EventId;
import com.vaadin.shared.ui.Connect;
import com.vaadin.v7.client.ui.VOptionGroup;
+import com.vaadin.v7.shared.ui.optiongroup.OptionGroupConstants;
import com.vaadin.v7.shared.ui.optiongroup.OptionGroupState;
import com.vaadin.v7.ui.OptionGroup;
@@ -34,7 +35,9 @@ public class OptionGroupConnector extends OptionGroupBaseConnector {
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- // HTML Content has been moved to state.
+ getWidget().htmlContentAllowed = uidl
+ .hasAttribute(OptionGroupConstants.HTML_CONTENT_ALLOWED);
+
super.updateFromUIDL(uidl, client);
getWidget().sendFocusEvents = client.hasEventListeners(this,
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
index 34090225ff..a7782b2e50 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/OptionGroup.java
@@ -51,6 +51,7 @@ public class OptionGroup extends AbstractSelect
implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
private Set<Object> disabledItemIds = new HashSet<Object>();
+ private boolean htmlContentAllowed = false;
public OptionGroup() {
super();
@@ -69,6 +70,15 @@ public class OptionGroup extends AbstractSelect
}
@Override
+ public void paintContent(PaintTarget target) throws PaintException {
+ if (isHtmlContentAllowed()) {
+ target.addAttribute(OptionGroupConstants.HTML_CONTENT_ALLOWED,
+ true);
+ }
+ super.paintContent(target);
+ }
+
+ @Override
protected void paintItem(PaintTarget target, Object itemId)
throws PaintException {
super.paintItem(target, itemId);
@@ -202,7 +212,8 @@ public class OptionGroup extends AbstractSelect
* text
*/
public void setHtmlContentAllowed(boolean htmlContentAllowed) {
- getState().htmlContentAllowed = htmlContentAllowed;
+ this.htmlContentAllowed = htmlContentAllowed;
+ markAsDirty();
}
/**
@@ -213,7 +224,7 @@ public class OptionGroup extends AbstractSelect
* @see #setHtmlContentAllowed(boolean)
*/
public boolean isHtmlContentAllowed() {
- return getState(false).htmlContentAllowed;
+ return htmlContentAllowed;
}
@Override
diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java
index 01f41174bd..092d673fce 100644
--- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java
+++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java
@@ -18,7 +18,7 @@ package com.vaadin.v7.shared.ui.optiongroup;
import java.io.Serializable;
public class OptionGroupConstants implements Serializable {
- // Vaadin 8 option group uses state for HTML content
+ public static final String HTML_CONTENT_ALLOWED = "usehtml";
public static final String ATTRIBUTE_OPTION_DISABLED = "disabled";
}
diff --git a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupState.java b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupState.java
index 167b1b31f0..ed88b4cb9f 100644
--- a/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupState.java
+++ b/compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupState.java
@@ -15,7 +15,6 @@
*/
package com.vaadin.v7.shared.ui.optiongroup;
-import com.vaadin.shared.annotations.DelegateToWidget;
import com.vaadin.v7.shared.ui.select.AbstractSelectState;
/**
@@ -27,7 +26,4 @@ public class OptionGroupState extends AbstractSelectState {
{
primaryStyleName = "v-select-optiongroup";
}
-
- @DelegateToWidget
- public boolean htmlContentAllowed = false;
}