Author: mbrohl
Date: Wed May 27 22:18:29 2015
New Revision: 1682132
URL: http://svn.apache.org/r1682132
Log:
Manually applied and modified the changes of the patch from jira issue
OFBIZ-6312: Catalog Manager's EditProduct screen HTML should place a limit on
the size of text that can be entered in the Product Description box.
Thanks Forrest Rae for reporting the issue and providing the patch.
Modified:
ofbiz/trunk/applications/product/webapp/catalog/product/EditProductContent.ftl
ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
ofbiz/trunk/framework/widget/dtd/widget-form.xsd
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java
ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl
ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl
Modified:
ofbiz/trunk/applications/product/webapp/catalog/product/EditProductContent.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/product/EditProductContent.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
---
ofbiz/trunk/applications/product/webapp/catalog/product/EditProductContent.ftl
(original)
+++
ofbiz/trunk/applications/product/webapp/catalog/product/EditProductContent.ftl
Wed May 27 22:18:29 2015
@@ -52,7 +52,7 @@ under the License.
<td width="20%" align="right"
valign="top"><b>${uiLabelMap.ProductProductDescription}</b></td>
<td> </td>
<td width="80%" colspan="4" valign="top">
- <textarea name="description" cols="60"
rows="2">${(product.description)!}</textarea>
+ <textarea name="description" cols="60" rows="2"
maxlength="255">${(product.description)!}</textarea>
</td>
</tr>
<tr>
Modified: ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml (original)
+++ ofbiz/trunk/applications/product/widget/catalog/ProductForms.xml Wed May 27
22:18:29 2015
@@ -353,7 +353,7 @@ under the License.
<field name="productId" title="${uiLabelMap.ProductDuplicateRemoveSelectedWithNewId}"
map-name="dupProduct"><text size="20" maxlength="20"/></field>
<field name="newInternalName" title="${uiLabelMap.ProductInternalName}"><text size="30"
maxlength="255"/></field>
<field name="newProductName" title="${uiLabelMap.ProductProductName}"><text size="30"
maxlength="60"/></field>
- <field name="newDescription" title="${uiLabelMap.ProductProductDescription}"
widget-style="textAreaBox"><textarea cols="60" rows="2"/></field>
+ <field name="newDescription" title="${uiLabelMap.ProductProductDescription}"
widget-style="textAreaBox"><textarea cols="60" rows="2" maxlength="255"/></field>
<field name="newLongDescription" title="${uiLabelMap.ProductLongDescription}" widget-style="textAreaBox
dojo-ResizableTextArea"><textarea cols="60" rows="7"/></field>
<field name="duplicateTitle" title="${uiLabelMap.CommonDuplicate}"
title-style="h1" map-name="dummy">
<display description=""/>
Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed May 27 22:18:29 2015
@@ -1615,6 +1615,7 @@ under the License.
<xs:complexType>
<xs:attribute type="xs:positiveInteger" name="cols" default="60"
/>
<xs:attribute type="xs:positiveInteger" name="rows" default="3" />
+ <xs:attribute type="xs:positiveInteger" name="maxlength"/>
<xs:attribute type="xs:string" name="default-value" />
<xs:attribute name="read-only" default="false">
<xs:annotation>
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
(original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/model/ModelFormField.java
Wed May 27 22:18:29 2015
@@ -3503,6 +3503,7 @@ public class ModelFormField {
private final int rows;
private final FlexibleStringExpander visualEditorButtons;
private final boolean visualEditorEnable;
+ private final Integer maxlength;
public TextareaField(Element element, ModelFormField modelFormField) {
super(element, modelFormField);
@@ -3534,6 +3535,17 @@ public class ModelFormField {
}
}
this.rows = rows;
+ Integer maxlength = null;
+ String maxlengthStr = element.getAttribute("maxlength");
+ if (!maxlengthStr.isEmpty()) {
+ try {
+ maxlength = Integer.valueOf(maxlengthStr);
+ } catch (NumberFormatException e) {
+ Debug.logError("Could not parse the max-length value of the
text element: [" + maxlengthStr
+ + "], setting to null; default of no maxlength will be
used", module);
+ }
+ }
+ this.maxlength = maxlength;
this.visualEditorButtons =
FlexibleStringExpander.getInstance(element.getAttribute("visual-editor-buttons"));
this.visualEditorEnable =
"true".equals(element.getAttribute("visual-editor-enable"));
}
@@ -3544,6 +3556,7 @@ public class ModelFormField {
this.defaultValue = FlexibleStringExpander.getInstance("");
this.readOnly = false;
this.rows = 2;
+ this.maxlength = null;
this.visualEditorButtons = FlexibleStringExpander.getInstance("");
this.visualEditorEnable = false;
}
@@ -3560,6 +3573,7 @@ public class ModelFormField {
this.readOnly = original.readOnly;
this.cols = original.cols;
this.rows = original.rows;
+ this.maxlength = original.maxlength;
}
@Override
@@ -3588,8 +3602,10 @@ public class ModelFormField {
}
}
- public int getRows() {
- return rows;
+ public int getRows() { return rows; }
+
+ public Integer getMaxlength() {
+ return maxlength;
}
public FlexibleStringExpander getVisualEditorButtons() {
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlFormRenderer.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlFormRenderer.java?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
---
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlFormRenderer.java
(original)
+++
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/html/HtmlFormRenderer.java
Wed May 27 22:18:29 2015
@@ -467,6 +467,13 @@ public class HtmlFormRenderer extends Ht
writer.append(Integer.toString(textareaField.getRows()));
writer.append('"');
+ Integer maxlength = textareaField.getMaxlength();
+ if(maxlength != null) {
+ writer.append(" maxlength=\"");
+ writer.append(Integer.toString(textareaField.getMaxlength()));
+ writer.append('"');
+ }
+
String idName = modelFormField.getCurrentContainerId(context);
if (UtilValidate.isNotEmpty(idName)) {
writer.append(" id=\"");
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
---
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java
(original)
+++
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/renderer/macro/MacroFormRenderer.java
Wed May 27 22:18:29 2015
@@ -455,6 +455,10 @@ public final class MacroFormRenderer imp
if (userLogin != null) {
language = UtilValidate.isEmpty((String) userLogin.get("lastLocale")) ?
"en" : (String) userLogin.get("lastLocale");
}
+ String maxlength = "";
+ if (textareaField.getMaxlength() != null) {
+ maxlength = Integer.toString(textareaField.getMaxlength());
+ }
String tabindex = modelFormField.getTabindex();
String value = modelFormField.getEntry(context,
textareaField.getDefaultValue(context));
StringWriter sr = new StringWriter();
@@ -471,6 +475,8 @@ public final class MacroFormRenderer imp
sr.append(cols);
sr.append("\" rows=\"");
sr.append(rows);
+ sr.append("\" maxlength=\"");
+ sr.append(maxlength);
sr.append("\" id=\"");
sr.append(id);
sr.append("\" readonly=\"");
Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Wed May 27
22:18:29 2015
@@ -26,7 +26,7 @@ under the License.
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask placeholder tabindex><@renderField value /></#macro>
-<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@renderField value /></#macro>
+<#macro renderTextareaField name className alert cols rows maxlength id readonly value
visualEditorEnable language buttons><@renderField value /></#macro>
<#macro renderDateTimeField name className alert title value size maxlength step timeValues id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName tabindex mask><@renderField value /></#macro>
Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Wed May 27
22:18:29 2015
@@ -52,7 +52,7 @@ under the License.
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask placeholder tabindex readonly><@makeBlock className value /></#macro>
-<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons><@makeBlock className value /></#macro>
+<#macro renderTextareaField name className alert cols rows maxlength id readonly value
visualEditorEnable language buttons><@makeBlock className value /></#macro>
<#macro renderDateTimeField name className alert title value size maxlength step timeValues id event action dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName mask><@makeBlock className value /></#macro>
Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Wed May 27
22:18:29 2015
@@ -74,7 +74,7 @@ under the License.
</#if>
</#macro>
-<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable buttons tabindex language="">
+<#macro renderTextareaField name className alert cols rows maxlength id readonly value
visualEditorEnable buttons tabindex language="">
<textarea name="${name}"<#t/>
<@renderClass className alert />
<#if cols?has_content> cols="${cols}"</#if><#rt/>
Modified: ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl Wed May 27
22:18:29 2015
@@ -26,7 +26,7 @@ under the License.
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask placeholder tabindex readonly><@renderField value /></#macro>
-<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable language buttons tabindex><@renderField value /></#macro>
+<#macro renderTextareaField name className alert cols rows maxlength id readonly value
visualEditorEnable language buttons tabindex><@renderField value /></#macro>
<#macro renderDateTimeField name className alert title value size maxlength id event action dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName tabindex><@renderField value /></#macro>
Modified: ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl?rev=1682132&r1=1682131&r2=1682132&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl Wed May 27
22:18:29 2015
@@ -42,7 +42,7 @@ under the License.
<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask placeholder tabindex readonly><@renderField value/></#macro>
-<#macro renderTextareaField name className alert cols rows id readonly value visualEditorEnable buttons tabindex language=""><@renderField value/></#macro>
+<#macro renderTextareaField name className alert cols rows maxlength id readonly value
visualEditorEnable buttons tabindex language=""><@renderField value/></#macro>
<#macro renderDateTimeField name className alert title value size maxlength id dateType shortDateInput timeDropdownParamName defaultDateTimeString localizedIconTitle timeDropdown timeHourName classString hour1 hour2 timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType formName tabindex mask="" event="" action="" step="" timeValues=""><@renderField value/></#macro>