@@ -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; | |||
} | |||
} |
@@ -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, |
@@ -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(); | |||
@@ -68,6 +69,15 @@ public class OptionGroup extends AbstractSelect | |||
super(caption); | |||
} | |||
@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 { | |||
@@ -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 |
@@ -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"; | |||
} |
@@ -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; | |||
} |