summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Negrea <snegrea@redhat.com>2012-09-10 16:38:33 (GMT)
committerStefan Negrea <snegrea@redhat.com>2012-09-10 16:38:33 (GMT)
commitd2047949ff60a8fb2ed84ebdc676eac4a49f1487 (patch)
tree7b54696cb76e4b2bb06d4634e72b621726d52560
parent47f97e620781574cf19e8a9473fc82ccdb8d0833 (diff)
downloadrhq-d2047949ff60a8fb2ed84ebdc676eac4a49f1487.zip
rhq-d2047949ff60a8fb2ed84ebdc676eac4a49f1487.tar.gz
rhq-d2047949ff60a8fb2ed84ebdc676eac4a49f1487.tar.xz
[BZ 851186] Updated the way default values are applied to fields on unset change.
Behaviour after update: 1) If the field is unset then disable field and set value to null 2) If the field is set then enable field and load saved value 3) On unset change from true to false, enable field and load default value if not null
-rw-r--r--modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index aec7274..5687ded 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -1293,6 +1293,11 @@ public class ConfigurationEditor extends LocatableVLayout {
protected FormItem buildSimpleField(final PropertyDefinitionSimple propertyDefinitionSimple,
final PropertySimple propertySimple) {
+ String value = propertySimple.getStringValue();
+ if (null == value && null != propertyDefinitionSimple.getDefaultValue()) {
+ value = propertyDefinitionSimple.getDefaultValue();
+ }
+
FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, propertySimple);
@@ -1302,6 +1307,7 @@ public class ConfigurationEditor extends LocatableVLayout {
// to wait until we implement masking/unmasking of PASSWORD props at the SLSB layer first.
if (propertyIsReadOnly && propertyDefinitionSimple.getType() != PropertySimpleType.PASSWORD) {
valueItem = new StaticTextItem();
+ valueItem.setValue(StringUtility.escapeHtml(value));
} else {
List<PropertyDefinitionEnumeration> enumeratedValues = propertyDefinitionSimple.getEnumeratedValues();
if (enumeratedValues != null && !enumeratedValues.isEmpty()) {
@@ -1361,6 +1367,12 @@ public class ConfigurationEditor extends LocatableVLayout {
List<Validator> validators = buildValidators(propertyDefinitionSimple, propertySimple);
valueItem.setValidators(validators.toArray(new Validator[validators.size()]));
+ if (isUnset(propertyDefinitionSimple, propertySimple)) {
+ setValue(valueItem, null);
+ } else {
+ valueItem.setValue(value);
+ }
+
if ((propertySimple.getConfiguration() != null) || (propertySimple.getParentMap() != null)
|| (propertySimple.getParentList() != null)) {
valueItem.addChangedHandler(new ChangedHandler() {
@@ -1403,16 +1415,6 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setTitle("none");
valueItem.setShowTitle(false);
- String value = propertySimple.getStringValue();
- if (null == value && null != propertyDefinitionSimple.getDefaultValue()) {
- value = propertyDefinitionSimple.getDefaultValue();
- }
- if (valueItem instanceof StaticTextItem) {
- // Property values are user-editable, so escape HTML when displayed as static text, to prevent XSS attacks.
- value = StringUtility.escapeHtml(value);
- }
- valueItem.setValue(value);
-
setValueAsTooltipIfAppropriate(valueItem, value);
valueItem.setRequired(propertyDefinitionSimple.isRequired());
@@ -1514,6 +1516,14 @@ public class ConfigurationEditor extends LocatableVLayout {
firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, true);
}
} else {
+ String defaultValue = propertyDefinitionSimple.getDefaultValue();
+ if (defaultValue != null) {
+ setValue(valueItem, defaultValue);
+ updatePropertySimpleValue(unsetItem, defaultValue, propertySimple, propertyDefinitionSimple);
+ boolean isValid = valueItem.validate();
+ firePropertyChangedEvent(propertySimple, propertyDefinitionSimple, isValid);
+ }
+
valueItem.focusInItem();
}