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");
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.
// 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(" ");
+ // 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(" ");
+ }
} else {
DOM.setInnerText(captionText, c);
}
captionText = null;
}
- if (uidl.hasAttribute(ATTRIBUTE_DESCRIPTION)) {
+ if (hasDescription) {
if (captionText != null) {
addStyleDependentName("hasdescription");
} else {
}
}
- if (uidl.getBooleanAttribute(ATTRIBUTE_REQUIRED)) {
+ if (showRequired) {
if (requiredFieldIndicator == null) {
requiredFieldIndicator = DOM.createDiv();
requiredFieldIndicator
requiredFieldIndicator = null;
}
- if (uidl.hasAttribute(ATTRIBUTE_ERROR)
- && !uidl.getBooleanAttribute(ATTRIBUTE_HIDEERRORS)) {
+ if (showError) {
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setInnerHTML(errorIndicatorElement, " ");