svn commit: r1098082 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/MacroFormRenderer.java src/org/ofbiz/widget/form/ModelFormField.java templates/htmlFormMacroLibrary.ftl

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

svn commit: r1098082 - in /ofbiz/trunk/framework/widget: dtd/widget-form.xsd src/org/ofbiz/widget/form/MacroFormRenderer.java src/org/ofbiz/widget/form/ModelFormField.java templates/htmlFormMacroLibrary.ftl

ashish-18
Author: ashish
Date: Sat Apr 30 09:05:20 2011
New Revision: 1098082

URL: http://svn.apache.org/viewvc?rev=1098082&view=rev
Log:
Applied patch from jira issue OFBIZ-4267. Disabled attribute for lookup field should be readonly.
Lookup tag has a attribute "disabled" that is used to set disabled="disabled" property for lookup input element and it create also a clear button just after lookup field to clear the field value.
But if we set disabled="disabled" for any input field then that field does not passes as parameter and we can't accesses it from parameters or request parameters , so it should be "readonly".
If we set readonly-"readonly" then user can't change the field value directly, and this field passes as parameters.
Only difference between readonly and disabled is that in case of disabled field does not passes as parameter buy in case of readonly field passes as a parameter.
Thanks Deepak for the contribution.

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=1098082&r1=1098081&r2=1098082&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Apr 30 09:05:20 2011
@@ -968,7 +968,7 @@ under the License.
                 </xs:restriction>
             </xs:simpleType>
         </xs:attribute>
-        <xs:attribute name="disabled" default="false">
+        <xs:attribute name="read-only" default="false">
             <xs:simpleType>
                 <xs:restriction base="xs:token">
                     <xs:enumeration value="true"/>

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=1098082&r1=1098081&r2=1098082&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 Sat Apr 30 09:05:20 2011
@@ -2086,7 +2086,7 @@ public class MacroFormRenderer implement
 
         String event = modelFormField.getEvent();
         String action = modelFormField.getAction(context);
-        boolean disabled = lookupField.disabled;
+        boolean readonly = lookupField.readonly;
 
         // add lookup pop-up button
         String descriptionFieldName = lookupField.getDescriptionFieldName();
@@ -2173,8 +2173,8 @@ public class MacroFormRenderer implement
         if (action != null) {
             sr.append(action);
         }
-        sr.append("\" disabled=");
-        sr.append(Boolean.toString(disabled));
+        sr.append("\" readonly=");
+        sr.append(Boolean.toString(readonly));
 
         sr.append(" autocomplete=\"");
         sr.append(autocomplete);

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=1098082&r1=1098081&r2=1098082&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 Sat Apr 30 09:05:20 2011
@@ -2850,6 +2850,7 @@ public class ModelFormField {
         protected FlexibleStringExpander defaultValue;
         protected SubHyperlink subHyperlink;
         protected boolean disabled;
+        protected boolean readonly;
         protected boolean clientAutocompleteField;
         protected String mask;
 
@@ -2890,6 +2891,7 @@ public class ModelFormField {
             }
 
             this.disabled = "true".equals(element.getAttribute("disabled"));
+            this.readonly = "true".equals(element.getAttribute("read-only"));
 
             this.clientAutocompleteField = !"false".equals(element.getAttribute("client-autocomplete-field"));
 
@@ -2920,6 +2922,14 @@ public class ModelFormField {
             this.disabled = b;
         }
 
+        public boolean getReadonly() {
+            return this.readonly;
+        }
+
+        public void setReadonly(boolean b) {
+            this.readonly = b;
+        }
+
         public boolean getClientAutocompleteField() {
             return this.clientAutocompleteField;
         }

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=1098082&r1=1098081&r2=1098082&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Sat Apr 30 09:05:20 2011
@@ -542,7 +542,7 @@ ${item.description}</span>
 </#if>
 </#macro>
 
-<#macro renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName fieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled presentation width height position fadeBackground clearText showDescription initiallyCollapsed>
+<#macro renderLookupField className alert name value size maxlength id event action readonly autocomplete descriptionFieldName formName fieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled presentation width height position fadeBackground clearText showDescription initiallyCollapsed>
 <#if ajaxEnabled?has_content && ajaxEnabled>
     <script type="text/javascript">
     jQuery(document).ready(function(){
@@ -553,7 +553,7 @@ ${item.description}</span>
     </script>
 </#if>
 <span class="field-lookup">
-<#if size?has_content && size=="0"><input type="hidden" <#if name?has_content> name="${name}"/></#if><#else><input type="text" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if id?has_content> id="${id}"</#if><#rt/><#if disabled?has_content && disabled> disabled="disabled"</#if><#rt/><#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/></#if>
+<#if size?has_content && size=="0"><input type="hidden" <#if name?has_content> name="${name}"/></#if><#else><input type="text" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if value?has_content> value="${value}"</#if><#if size?has_content> size="${size}"</#if><#if maxlength?has_content> maxlength="${maxlength}"</#if><#if id?has_content> id="${id}"</#if><#rt/><#if readonly?has_content && readonly> readonly="readonly"</#if><#rt/><#if event?has_content && action?has_content> ${event}="${action}"</#if><#rt/><#if autocomplete?has_content> autocomplete="off"</#if>/><#rt/></#if>
 <#if presentation?has_content && descriptionFieldName?has_content && presentation == "window">
      <a href="javascript:call_fieldlookup3(document.${formName?html}.${name?html},document.${formName?html}.${descriptionFieldName},'${fieldFormName}', '${presentation}'<#rt/>
     <#if targetParameterIter?has_content>
@@ -606,7 +606,7 @@ ${item.description}</span>
         });
     </script>
 </#if>
-<#if disabled?has_content && disabled><a id="${id}_clear" style="background:none;margin-left:5px;margin-right:15px;" class="clearField" href="javascript:void();" onclick="javascript:document.${formName}.${name}.value='';<#if descriptionFieldName?has_content>document.${formName}.${descriptionFieldName}.value='';</#if>">${clearText}</a></#if>
+<#if readonly?has_content && readonly><a id="${id}_clear" style="background:none;margin-left:5px;margin-right:15px;" class="clearField" href="javascript:void();" onclick="javascript:document.${formName}.${name}.value='';<#if descriptionFieldName?has_content>document.${formName}.${descriptionFieldName}.value='';</#if>">${clearText}</a></#if>
 </span>
 <#if ajaxEnabled?has_content && ajaxEnabled>
       <#if parameters?has_content && parameters._LAST_VIEW_NAME_?has_content && ajaxUrl?index_of("_LAST_VIEW_NAME_") < 0>