You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2006/11/18 22:09:59 UTC

svn commit: r476606 - in /incubator/ofbiz/trunk/framework: common/config/CommonUiLabels.properties common/config/CommonUiLabels_fr.properties widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Author: jonesde
Date: Sat Nov 18 13:09:57 2006
New Revision: 476606

URL: http://svn.apache.org/viewvc?view=rev&rev=476606
Log:
Applied patch from Jean-Sebastien Hederer with some improvements to the date-time field for different types to format the output and such, plus a couple of minor changes; Jira #OFBIZ-470

Modified:
    incubator/ofbiz/trunk/framework/common/config/CommonUiLabels.properties
    incubator/ofbiz/trunk/framework/common/config/CommonUiLabels_fr.properties
    incubator/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Modified: incubator/ofbiz/trunk/framework/common/config/CommonUiLabels.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/config/CommonUiLabels.properties?view=diff&rev=476606&r1=476605&r2=476606
==============================================================================
--- incubator/ofbiz/trunk/framework/common/config/CommonUiLabels.properties (original)
+++ incubator/ofbiz/trunk/framework/common/config/CommonUiLabels.properties Sat Nov 18 13:09:57 2006
@@ -1,5 +1,4 @@
 #####################################################################
-#
 # Copyright 2001-2006 The Apache Software Foundation
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -160,8 +159,10 @@
 CommonFollowingOccurred=The Following Occurred
 CommonFor=For
 CommonForgotYourPassword=Forgot Your Password
-CommonFormatDateFieldNotCorrect=One of the date field is incorrect, format must be AAAA-mm-jj HH:mm:ss
-CommonFormatDateTime=YYYY-MM-DD hh:mm:ss
+CommonFormatDate=Format: yyyy-MM-dd
+CommonFormatDateFieldNotCorrect=One of the date fields is incorrect, format must be yyyy-MM-dd HH:mm:ss.SSS
+CommonFormatDateTime=Format: yyyy-MM-dd HH:mm:ss.SSS
+CommonFormatTime=Format: HH:mm:ss.SSS
 CommonFound=Found
 CommonFriday=Friday
 CommonFrom=From

Modified: incubator/ofbiz/trunk/framework/common/config/CommonUiLabels_fr.properties
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/common/config/CommonUiLabels_fr.properties?view=diff&rev=476606&r1=476605&r2=476606
==============================================================================
--- incubator/ofbiz/trunk/framework/common/config/CommonUiLabels_fr.properties (original)
+++ incubator/ofbiz/trunk/framework/common/config/CommonUiLabels_fr.properties Sat Nov 18 13:09:57 2006
@@ -154,8 +154,10 @@
 CommonFollowingOccurred=Ce qui suit s'est produit
 CommonFor=pour
 CommonForgotYourPassword=Vous avez oubli\u00E9 votre mot de passe
+CommonFormatDate=Format: AAAA-MM-JJ
 CommonFormatDateFieldNotCorrect=La saisie d'un champ de date est incorrecte, le format doit-\u00EAtre AAAA-mm-jj HH:mm:ss
-CommonFormatDateTime=AAAA-MM-JJ  /  hh:mm:ss
+CommonFormatDateTime=Format: AAAA-MM-JJ hh:mm:ss.sss
+CommonFormatTime=Format: hh:mm:ss
 CommonFound=Trouv\u00E9
 CommonFriday=Vendredi
 CommonFrom=De

Modified: incubator/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?view=diff&rev=476606&r1=476605&r2=476606
==============================================================================
--- incubator/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ incubator/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Sat Nov 18 13:09:57 2006
@@ -346,6 +346,12 @@
         ModelFormField modelFormField = dateTimeField.getModelFormField();
         String paramName = modelFormField.getParameterName(context);
         String defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context);
+        
+        Map uiLabelMap = (Map) context.get("uiLabelMap");
+        if (uiLabelMap == null) {
+            Debug.logWarning("Could not find uiLabelMap in context", module);
+        }
+        String localizedInputTitle = "" , localizedIconTitle = "";
 
         // whether the date field is short form, yyyy-mm-dd
         boolean shortDateInput = ("date".equals(dateTimeField.getType()) || "time-dropdown".equals(dateTimeField.getInputMethod()) ? true : false);
@@ -372,31 +378,38 @@
         }
         buffer.append('"');
 
-        String value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context));
-        if (UtilValidate.isNotEmpty(value)) {
-            buffer.append(" value=\"");
-            if ("date".equals(dateTimeField.getType()) && value.length()>=10) {
-                value = value.substring(0, 10);
-            } else if ("time".equals(dateTimeField.getType()) && value.length()>=16) {
-                value = value.substring(0, 16);
-            }
-
-            buffer.append(value);
-            buffer.append('"');
-        }
-
         // the default values for a timestamp
         int size = 25;
         int maxlength = 30;
 
         if (shortDateInput) {
-            size = 10;
-            maxlength = 10;
+            size = maxlength = 10;
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatDate");
+            }
         } else if ("time".equals(dateTimeField.getType())) {
-            size = 16;
-            maxlength = 16;
+            size = maxlength = 8;
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatTime");
+            }
+        } else {
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatDateTime");
+            }
         }
-
+        buffer.append(" title=\"");
+        buffer.append(localizedInputTitle);
+        buffer.append('"');
+        
+        String value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context));
+        if (UtilValidate.isNotEmpty(value)) {
+            if(value.length() > maxlength)
+                value = value.substring(0, maxlength-1);
+            buffer.append(" value=\"");
+            buffer.append(value);
+            buffer.append('"');
+        }
+        
         buffer.append(" size=\"");
         buffer.append(size);
         buffer.append('"');
@@ -414,6 +427,11 @@
 
         buffer.append("/>");
 
+        // search for a localized label for the icon
+        if (uiLabelMap != null) {
+            localizedIconTitle = (String) uiLabelMap.get("CommonViewCalendar");
+        }
+
         // add calendar pop-up button and seed data IF this is not a "time" type date-time
         if (!"time".equals(dateTimeField.getType())) {
             if (shortDateInput) {
@@ -431,11 +449,16 @@
             buffer.append(",'");
             buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString)));
             buffer.append("');\">");
+           
             buffer.append("<img src=\"");
             this.appendContentUrl(buffer, "/images/cal.gif");
-            buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
+            buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\" title=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\"/></a>");
         }
-
+        
         // if we have an input method of time-dropdown, then render two dropdowns
         if ("time-dropdown".equals(dateTimeField.getInputMethod())) {       		
             String classString = (className != null ? " class=\"" + className + "\" " : "");
@@ -456,7 +479,7 @@
             buffer.append("&nbsp;<select name=\"").append(UtilHttp.makeCompositeParam(paramName, "hour")).append("\"");
             buffer.append(classString).append(">");
 
-            // keep the two cases separate because it's hard to unerstand a combined loop
+            // keep the two cases separate because it's hard to understand a combined loop
             if (isTwelveHour) {
                 for (int i = 1; i <= 12; i++) {
                     buffer.append("<option value=\"").append(i).append("\"");
@@ -1626,6 +1649,12 @@
         String opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale);
         String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
 
+        Map uiLabelMap = (Map) context.get("uiLabelMap");
+        if (uiLabelMap == null) {
+            Debug.logWarning("Could not find uiLabelMap in context", module);
+        }
+        String localizedInputTitle = "", localizedIconTitle = "";
+
         buffer.append("<input type=\"text\"");
 
         String className = modelFormField.getWidgetStyle();
@@ -1644,17 +1673,38 @@
         buffer.append(modelFormField.getParameterName(context));
         buffer.append("_fld0_value\"");
 
+        // the default values for a timestamp
+        int size = 25;
+        int maxlength = 30;
+
+        if ("date".equals(dateFindField.getType())) {
+            size = maxlength = 10;
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatDate");
+            }
+        } else if ("time".equals(dateFindField.getType())) {
+            size = maxlength = 8;
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatTime");
+            }
+        } else {
+            if (uiLabelMap != null) {
+                localizedInputTitle = (String) uiLabelMap.get("CommonFormatDateTime");
+            }
+        }
+        buffer.append(" title=\"");
+        buffer.append(localizedInputTitle);
+        buffer.append('"');
+
         String value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
         if (UtilValidate.isNotEmpty(value)) {
+            if(value.length() > maxlength)
+                value = value.substring(0, maxlength-1);
             buffer.append(" value=\"");
             buffer.append(value);
             buffer.append('"');
         }
 
-        // the default values for a timestamp
-        int size = 25;
-        int maxlength = 30;
-
         buffer.append(" size=\"");
         buffer.append(size);
         buffer.append('"');
@@ -1665,17 +1715,33 @@
 
         buffer.append("/>");
 
-        // add calendar pop-up button and seed data 
-        buffer.append("<a href=\"javascript:call_cal(document.");
-        buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
-        buffer.append('.');
-        buffer.append(modelFormField.getParameterName(context));
-        buffer.append("_fld0_value,'");
-        buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
-        buffer.append("');\">");
-        buffer.append("<img src=\"");
-        this.appendContentUrl(buffer, "/images/cal.gif");
-        buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
+        // search for a localized label for the icon
+        if (uiLabelMap != null) {
+            localizedIconTitle = (String) uiLabelMap.get("CommonViewCalendar");
+        } 
+
+        // add calendar pop-up button and seed data IF this is not a "time" type date-find
+        if (!"time".equals(dateFindField.getType())) {
+            if ("date".equals(dateFindField.getType())) {
+                buffer.append("<a href=\"javascript:call_cal_notime(document.");
+            } else {
+                buffer.append("<a href=\"javascript:call_cal(document.");            
+            }
+            buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
+            buffer.append('.');
+            buffer.append(modelFormField.getParameterName(context));
+            buffer.append("_fld0_value,'");
+            buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
+            buffer.append("');\">");
+
+            buffer.append("<img src=\"");
+            this.appendContentUrl(buffer, "/images/cal.gif");
+            buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\" title=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\"/></a>");
+        }
 
         buffer.append(" <span");
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
@@ -1715,8 +1781,14 @@
         buffer.append(modelFormField.getParameterName(context));
         buffer.append("_fld1_value\"");
 
+        buffer.append(" title=\"");
+        buffer.append(localizedInputTitle);
+        buffer.append('"');
+
         value = modelFormField.getEntry(context);
         if (UtilValidate.isNotEmpty(value)) {
+            if(value.length() > maxlength)
+                value = value.substring(0, maxlength-1);
             buffer.append(" value=\"");
             buffer.append(value);
             buffer.append('"');
@@ -1732,17 +1804,28 @@
 
         buffer.append("/>");
 
-        // add calendar pop-up button and seed data 
-        buffer.append("<a href=\"javascript:call_cal(document.");
-        buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
-        buffer.append('.');
-        buffer.append(modelFormField.getParameterName(context));
-        buffer.append("_fld1_value,'");
-        buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
-        buffer.append("');\">");
-        buffer.append("<img src=\"");
-        this.appendContentUrl(buffer, "/images/cal.gif");
-        buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
+        // add calendar pop-up button and seed data IF this is not a "time" type date-find
+        if (!"time".equals(dateFindField.getType())) {
+            if ("date".equals(dateFindField.getType())) {
+                buffer.append("<a href=\"javascript:call_cal_notime(document.");
+            } else {
+                buffer.append("<a href=\"javascript:call_cal(document.");            
+            }
+            buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
+            buffer.append('.');
+            buffer.append(modelFormField.getParameterName(context));
+            buffer.append("_fld1_value,'");
+            buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
+            buffer.append("');\">");
+
+            buffer.append("<img src=\"");
+            this.appendContentUrl(buffer, "/images/cal.gif");
+            buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\" title=\"");
+            buffer.append(localizedIconTitle);
+            buffer.append("\"/></a>");
+        }
 
         buffer.append(" <span");
         if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {