Author: adrianc
Date: Wed Oct 9 14:54:40 2013 New Revision: 1530656 URL: http://svn.apache.org/r1530656 Log: New feature - add placeholder to form widget. Patch contributed by Sumit Pandit. https://issues.apache.org/jira/browse/OFBIZ-5341 Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1530656&r1=1530655&r2=1530656&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Wed Oct 9 14:54:40 2013 @@ -764,6 +764,11 @@ under the License. </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute name="placeholder" type="xs:string"> + <xs:annotation> + <xs:documentation>Specifies a short hint that describes the expected value of an input field.</xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> <xs:element name="display" substitutionGroup="AllFields"> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1530656&r1=1530655&r2=1530656&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Wed Oct 9 14:54:40 2013 @@ -319,6 +319,7 @@ public class MacroFormRenderer implement String className = ""; String alert = "false"; String mask = ""; + String placeholder = textField.getPlaceholder(context); if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) { className = modelFormField.getWidgetStyle(); if (modelFormField.shouldBeRed(context)) { @@ -389,6 +390,8 @@ public class MacroFormRenderer implement sr.append(Boolean.toString(ajaxEnabled)); sr.append(" mask=\""); sr.append(mask); + sr.append("\" placeholder=\""); + sr.append(placeholder); sr.append("\" />"); executeMacro(writer, sr.toString()); ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink(); 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=1530656&r1=1530655&r2=1530656&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 Wed Oct 9 14:54:40 2013 @@ -2724,6 +2724,7 @@ public class ModelFormField { protected boolean readonly; protected boolean clientAutocompleteField; protected String mask; + protected FlexibleStringExpander placeholder = FlexibleStringExpander.getInstance(null); protected TextField() { super(); @@ -2741,7 +2742,7 @@ public class ModelFormField { super(element, modelFormField); this.setDefaultValue(element.getAttribute("default-value")); this.mask = element.getAttribute("mask"); - + this.placeholder = FlexibleStringExpander.getInstance(element.getAttribute("placeholder")); String sizeStr = element.getAttribute("size"); try { size = Integer.parseInt(sizeStr); @@ -2848,6 +2849,10 @@ public class ModelFormField { public String getMask() { return this.mask; } + + public String getPlaceholder(Map<String, Object> context) { + return this.placeholder.expandString(context); + } } public static class TextareaField extends FieldInfo { Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1530656&r1=1530655&r2=1530656&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Wed Oct 9 14:54:40 2013 @@ -48,7 +48,7 @@ under the License. </#macro> <#macro renderHyperlinkField></#macro> -<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask> +<#macro renderTextField name className alert value textSize maxlength id event action disabled clientAutocomplete ajaxUrl ajaxEnabled mask placeholder=""> <#if mask?has_content> <script type="text/javascript"> jQuery(function($){jQuery("#${id}").mask("${mask}");}); @@ -63,6 +63,7 @@ under the License. <#if id?has_content> id="${id}"</#if><#rt/> <#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/> <#if clientAutocomplete?has_content && clientAutocomplete=="false"> autocomplete="off"</#if><#rt/> + <#if placeholder?has_content> placeholder="${placeholder}"</#if><#rt/> /><#t/> <#if ajaxEnabled?has_content && ajaxEnabled> <#assign defaultMinLength = Static["org.ofbiz.base.util.UtilProperties"].getPropertyValue("widget.properties", "widget.autocompleter.defaultMinLength")> |
Free forum by Nabble | Edit this page |