You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2009/04/16 18:11:53 UTC

svn commit: r765674 - in /ofbiz/trunk/framework/widget: src/org/ofbiz/widget/form/MacroFormRenderer.java templates/foFormMacroLibrary.ftl templates/htmlFormMacroLibrary.ftl templates/textFormMacroLibrary.ftl templates/xmlFormMacroLibrary.ftl

Author: jacopoc
Date: Thu Apr 16 16:11:53 2009
New Revision: 765674

URL: http://svn.apache.org/viewvc?rev=765674&view=rev
Log:
Migrated to the form widget macro renderer the code that adds ajax support to submit buttons.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
    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/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=765674&r1=765673&r2=765674&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 Thu Apr 16 16:11:53 2009
@@ -851,6 +851,24 @@
                 alert = "true";
             }
         }
+
+        String formId = modelForm.getContainerId();
+        List<ModelForm.UpdateArea> updateAreas = modelForm.getOnSubmitUpdateAreas();
+        // This is here for backwards compatibility. Use on-event-update-area
+        // elements instead.
+        String backgroundSubmitRefreshTarget = submitField.getBackgroundSubmitRefreshTarget(context);
+        if (UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) {
+            if (updateAreas == null) {
+                updateAreas = FastList.newInstance();
+            }
+            updateAreas.add(new ModelForm.UpdateArea("submit", formId, backgroundSubmitRefreshTarget));
+        }
+
+        boolean ajaxEnabled = (updateAreas != null || UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) && this.javaScriptEnabled;
+        String ajaxUrl = "";
+        if (ajaxEnabled) {
+            ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
+        }
         StringWriter sr = new StringWriter();
         sr.append("<@renderSubmitField ");
         sr.append("buttonType=\"");
@@ -875,6 +893,14 @@
         }
         sr.append("\" imgSrc=\"");
         sr.append(imgSrc);
+        sr.append("\" containerId=\"");
+        if (ajaxEnabled) {
+            sr.append(formId);
+        }
+        sr.append("\" ajaxUrl=\"");
+        if (ajaxEnabled) {
+            sr.append(ajaxUrl);
+        }
         sr.append("\" />");
         executeMacro(writer, sr.toString());
         this.appendTooltip(writer, context, modelFormField);

Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=765674&r1=765673&r2=765674&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Thu Apr 16 16:11:53 2009
@@ -59,7 +59,7 @@
 <#macro renderCheckField items className alert allChecked currentValue name event action><@makeBlock "" "" /></#macro>
 <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event ation><@makeBlock "" "" /></#macro>
 
-<#macro renderSubmitField buttonType className alert formName title name event action imgSrc><@makeBlock "" "" /></#macro>
+<#macro renderSubmitField buttonType className alert formName title name event action imgSrc containerId ajaxUrl><@makeBlock "" "" /></#macro>
 <#macro renderResetField className alert name title><@makeBlock "" "" /></#macro>
 
 <#macro renderHiddenField name value></#macro>

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=765674&r1=765673&r2=765674&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Thu Apr 16 16:11:53 2009
@@ -136,13 +136,13 @@
 </#list>
 </#macro>
 
-<#macro renderSubmitField buttonType className alert formName title name event action imgSrc>
+<#macro renderSubmitField buttonType className alert formName title name event action imgSrc containerId ajaxUrl>
 <#if buttonType=="text-link">
  <a <@renderClass className alert /> href="javascript:document.${formName}.submit()"><#if title?has_content>${title}</#if> </a>
 <#elseif buttonType=="image">
  <input type="image" src="${imgSrc}" <@renderClass className alert /><#if name?has_content> name="${name}"</#if><#if title?has_content> alt="${title}"</#if><#if event?has_content> ${event}="${action}"</#if> />
 <#else>
-<input type="submit" <@renderClass className alert /><#if name?exists> name="${name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if> /></#if>
+<input type="<#if containerId?has_content>button<#else>submit</#if>" <@renderClass className alert /><#if name?exists> name="${name}"</#if><#if title?has_content> value="${title}"</#if><#if event?has_content> ${event}="${action}"</#if><#if containerId?has_content> onclick="ajaxSubmitFormUpdateAreas('${containerId}', '${ajaxUrl}')"</#if>/></#if>
 </#macro>
 <#macro renderResetField className alert name title><input type="reset" <@renderClass className alert /> name="${name}"<#if title?has_content> value="${title}"</#if>/></#macro>
 

Modified: ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl?rev=765674&r1=765673&r2=765674&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl Thu Apr 16 16:11:53 2009
@@ -41,7 +41,7 @@
 <#macro renderCheckField items className alert allChecked currentValue name event action></#macro>
 <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event ation></#macro>
 
-<#macro renderSubmitField buttonType className alert formName title name event action imgSrc></#macro>
+<#macro renderSubmitField buttonType className alert formName title name event action imgSrc containerId ajaxUrl></#macro>
 <#macro renderResetField className alert name title></#macro>
 
 <#macro renderHiddenField name value></#macro>

Modified: ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl?rev=765674&r1=765673&r2=765674&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/xmlFormMacroLibrary.ftl Thu Apr 16 16:11:53 2009
@@ -55,7 +55,7 @@
 <#macro renderCheckField items className alert allChecked currentValue name event action></#macro>
 <#macro renderRadioField items className alert currentValue noCurrentSelectedKey name event action></#macro>
 
-<#macro renderSubmitField buttonType className alert formName title name event action imgSrc></#macro>
+<#macro renderSubmitField buttonType className alert formName title name event action imgSrc containerId ajaxUrl></#macro>
 <#macro renderResetField className alert name title></#macro>
 
 <#macro renderHiddenField name value></#macro>