Author: adrianc
Date: Fri Apr 24 02:02:40 2009
New Revision: 768123
URL: http://svn.apache.org/viewvc?rev=768123&view=rev
Log:
Fixed a bug in Label Manager where empty values were not saved properly.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=768123&r1=768122&r2=768123&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java
(original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/StringUtil.java Fri Apr
24 02:02:40 2009
@@ -598,6 +598,7 @@
if (insertBR) {
html = StringUtil.replaceString(html, "<br>", "\n");
}
+ html = html.replace(" ", " ");
return html;
}
Modified:
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=768123&r1=768122&r2=768123&view=diff
==============================================================================
---
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
(original)
+++
ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java
Fri Apr 24 02:02:40 2009
@@ -86,16 +86,17 @@
for (String localeFound : localesFound) {
LabelValue labelValue =
labelInfo.getLabelValue(localeFound);
-
- if (UtilValidate.isNotEmpty(labelValue)) {
- Element valueElem = null;
- if
("CommonEmptyHeader#CommonUiLabels.xml".equalsIgnoreCase(labelKey)) {
- valueElem =
UtilXml.addChildElementValue(propertyElem, "value", " ",
resourceDocument); // This is needed to keep the label not "empty"
- } else {
- valueElem =
UtilXml.addChildElementValue(propertyElem, "value",
StringUtil.fromHtmlToSpecialChars(labelValue.getLabelValue(), true, true,
false), resourceDocument);
- }
+ String valueString = null;
+ if (labelValue != null) {
+ valueString = labelValue.getLabelValue();
+ }
+ if (UtilValidate.isNotEmpty(valueString)) {
+ valueString =
StringUtil.fromHtmlToSpecialChars(valueString, true, true, true);
+ Element valueElem =
UtilXml.addChildElementValue(propertyElem, "value", valueString,
resourceDocument);;
valueElem.setAttribute("xml:lang", localeFound);
-
+ if (valueString.trim().length() == 0) {
+ valueElem.setAttribute("xml:space",
"preserve");
+ }
if
(UtilValidate.isNotEmpty(labelValue.getLabelComment())) {
Comment labelComment =
resourceDocument.createComment(StringUtil.fromHtmlToSpecialChars(labelValue.getLabelComment(),
true, true, false));
Node parent = valueElem.getParentNode();
@@ -105,7 +106,7 @@
}
}
- if (UtilValidate.isNotEmpty(resourceElem) &&
UtilValidate.isNotEmpty(uri)) {
+ if (UtilValidate.isNotEmpty(uri)) {
File outFile = new File(new URI(uri));
FileOutputStream fos = new FileOutputStream(outFile);
OutputFormat format = new
OutputFormat(resourceDocument.getDocumentElement().getOwnerDocument(), "UTF-8",
true);