svn commit: r1129877 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1129877 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

erwan
Author: erwan
Date: Tue May 31 19:37:39 2011
New Revision: 1129877

URL: http://svn.apache.org/viewvc?rev=1129877&view=rev
Log:
Adding help text when displaying a field, code directly copied from MacroFormRenderer.renderFieldTitle

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1129877&r1=1129876&r2=1129877&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue May 31 19:37:39 2011
@@ -41,6 +41,8 @@ import org.ofbiz.base.util.UtilPropertie
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.StringUtil.SimpleEncoder;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.base.util.template.FreeMarkerWorker;
+import org.ofbiz.entity.Delegator;
 import org.ofbiz.webapp.control.RequestHandler;
 import org.ofbiz.webapp.taglib.ContentUrlTag;
 import org.ofbiz.widget.ModelWidget;
@@ -69,6 +71,7 @@ import org.ofbiz.widget.form.ModelFormFi
 import org.ofbiz.widget.form.ModelFormField.TextField;
 import org.ofbiz.widget.form.ModelFormField.TextFindField;
 import org.ofbiz.widget.form.ModelFormField.TextareaField;
+import org.ofbiz.widget.form.UtilHelpText;
 
 import com.ibm.icu.util.Calendar;
 
@@ -1271,9 +1274,26 @@ public class HtmlFormRenderer extends Ht
         String titleText = UtilHttp.encodeAmpersands(tempTitleText);
 
         if (UtilValidate.isNotEmpty(titleText)) {
-            if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
-                writer.append("<span class=\"");
-                writer.append(modelFormField.getTitleStyle());
+            // copied from MacroFormRenderer renderFieldTitle
+            String displayHelpText = UtilProperties.getPropertyValue("widget.properties", "widget.form.displayhelpText");
+            String helpText = null;
+            if ("Y".equals(displayHelpText)) {
+                Delegator delegator = WidgetWorker.getDelegator(context);
+                Locale locale = (Locale)context.get("locale");
+                String entityName = modelFormField.getEntityName();
+                String fieldName = modelFormField.getFieldName();
+                helpText = UtilHelpText.getEntityFieldDescription(entityName, fieldName, delegator, locale);
+            }
+            if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle()) || UtilValidate.isNotEmpty(helpText)) {
+                writer.append("<span");
+                if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())){
+                    writer.append(" class=\"");
+                    writer.append(modelFormField.getTitleStyle());
+                }
+                if (UtilValidate.isNotEmpty(helpText)){
+                    writer.append(" title=\"");
+                    writer.append(FreeMarkerWorker.encodeDoubleQuotes(helpText));
+                }
                 writer.append("\">");
             }
             if (" ".equals(titleText)) {