aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-04-09 07:18:47 +0000
committerArtur Signell <artur.signell@itmill.com>2010-04-09 07:18:47 +0000
commit75a161edf45f7d52596b7fee7b680f5cbc3db7b1 (patch)
treeb69e9970c3dc56717797decb73e7a9754595b861 /src/com/vaadin
parentd51ba748576c06a93c08d4f5bd9398696668131a (diff)
downloadvaadin-framework-75a161edf45f7d52596b7fee7b680f5cbc3db7b1.tar.gz
vaadin-framework-75a161edf45f7d52596b7fee7b680f5cbc3db7b1.zip
Additional fix for #3846 - Do not add an extra &nbsp; if there is an icon, an error or required indicator
svn changeset:12412/svn branch:6.3
Diffstat (limited to 'src/com/vaadin')
-rw-r--r--src/com/vaadin/terminal/gwt/client/VCaption.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/VCaption.java b/src/com/vaadin/terminal/gwt/client/VCaption.java
index 8018875137..af0cdecfea 100644
--- a/src/com/vaadin/terminal/gwt/client/VCaption.java
+++ b/src/com/vaadin/terminal/gwt/client/VCaption.java
@@ -91,7 +91,14 @@ public class VCaption extends HTML {
setStyleName(style);
- if (uidl.hasAttribute(ATTRIBUTE_ICON)) {
+ boolean hasIcon = uidl.hasAttribute(ATTRIBUTE_ICON);
+ boolean hasText = uidl.hasAttribute(ATTRIBUTE_CAPTION);
+ boolean hasDescription = uidl.hasAttribute(ATTRIBUTE_DESCRIPTION);
+ boolean showRequired = uidl.getBooleanAttribute(ATTRIBUTE_REQUIRED);
+ boolean showError = uidl.hasAttribute(ATTRIBUTE_ERROR)
+ && !uidl.getBooleanAttribute(ATTRIBUTE_HIDEERRORS);
+
+ if (hasIcon) {
if (icon == null) {
icon = new Icon(client);
icon.setWidth("0");
@@ -112,7 +119,7 @@ public class VCaption extends HTML {
icon = null;
}
- if (uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
+ if (hasText) {
// A caption text should be shown if the attribute is set
// If the caption is null the ATTRIBUTE_CAPTION should not be set to
// avoid ending up here.
@@ -133,8 +140,12 @@ public class VCaption extends HTML {
// Not sure if c even can be null. Should not.
// This is required to ensure that the caption uses space in all
- // browsers when it is set to the empty string.
- captionText.setInnerHTML("&nbsp;");
+ // browsers when it is set to the empty string. If there is an
+ // icon, error indicator or required indicator they will ensure
+ // that space is reserved.
+ if (!hasIcon && !showRequired && !showError) {
+ captionText.setInnerHTML("&nbsp;");
+ }
} else {
DOM.setInnerText(captionText, c);
}
@@ -145,7 +156,7 @@ public class VCaption extends HTML {
captionText = null;
}
- if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
+ if (hasDescription) {
if (captionText != null) {
addStyleDependentName("hasdescription");
} else {
@@ -153,7 +164,7 @@ public class VCaption extends HTML {
}
}
- if (uidl.getBooleanAttribute(ATTRIBUTE_REQUIRED)) {
+ if (showRequired) {
if (requiredFieldIndicator == null) {
requiredFieldIndicator = DOM.createDiv();
requiredFieldIndicator
@@ -169,8 +180,7 @@ public class VCaption extends HTML {
requiredFieldIndicator = null;
}
- if (uidl.hasAttribute(ATTRIBUTE_ERROR)
- && !uidl.getBooleanAttribute(ATTRIBUTE_HIDEERRORS)) {
+ if (showError) {
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setInnerHTML(errorIndicatorElement, "&nbsp;");