Ha indeed, I remember now having seen a comment about that when doing r1377253.
Please refactor it if you think it's worth it.  Then some other cases in 
ModelFormField class could be changed as well (at least
those spotted in r1377253)

Jacques

From: "Adrian Crum" <[email protected]>
The UtilValidate.isNotEmpty(tooltip) method call is unnecessary. FSE will 
return an empty String if the original String was null
or empty. A more efficient way of doing this would be:

String tooltipString = tooltip.expandString(context);
if (!tooltipString.isEmpty()) {
    StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) 
context.get("simpleEncoder");
    if (simpleEncoder != null) {
        tooltipString = simpleEncoder.encode(tooltipString);
    }
 }


-Adrian

On 8/26/2012 9:35 AM, [email protected] wrote:
Author: jleroux
Date: Sun Aug 26 08:35:34 2012
New Revision: 1377388

URL: http://svn.apache.org/viewvc?rev=1377388&view=rev
Log:
Unlike descriptions and values, tooltips were not encoded, thanks to Scott for 
spotting it (r1377382 was flawed)

Modified:
     ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java

Modified: 
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1377388&r1=1377387&r2=1377388&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java 
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java 
Sun Aug 26 08:35:34 2012
@@ -953,10 +953,14 @@ public class ModelFormField {
      }
  public String getTooltip(Map<String, Object> context) {
-        if (UtilValidate.isNotEmpty(tooltip)) return 
tooltip.expandString(context);
-            return "";
+        String tooltipString = "";
+        if (UtilValidate.isNotEmpty(tooltip)) tooltipString = 
tooltip.expandString(context);
+        if (this.getEncodeOutput()) {
+            StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) 
context.get("simpleEncoder");
+            if (simpleEncoder != null) tooltipString = 
simpleEncoder.encode(tooltipString);
          }
-
+        return tooltipString;
+    }
      public String getUseWhen(Map<String, Object> context) {
          if (UtilValidate.isNotEmpty(this.useWhen)) return 
this.useWhen.expandString(context);



Reply via email to