You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by bi...@apache.org on 2010/04/04 12:38:19 UTC

svn commit: r930660 - in /ofbiz/trunk: applications/product/webapp/catalog/ framework/base/src/org/ofbiz/base/util/ framework/common/webcommon/includes/ framework/webtools/webapp/webtools/entity/ framework/widget/config/ framework/widget/templates/

Author: bibryam
Date: Sun Apr  4 10:38:19 2010
New Revision: 930660

URL: http://svn.apache.org/viewvc?rev=930660&view=rev
Log:
Committed a patch from OFBIZ-3541 "Using Widgets html form templates in FTL files". This change will make autocompleter available also in ftl lookups.

Added:
    ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl   (with props)
Modified:
    ofbiz/trunk/applications/product/webapp/catalog/main.ftl
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
    ofbiz/trunk/framework/webtools/webapp/webtools/entity/ListGeneric.ftl
    ofbiz/trunk/framework/widget/config/freemarkerImports.properties
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/applications/product/webapp/catalog/main.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/main.ftl?rev=930660&r1=930659&r2=930660&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/main.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/main.ftl Sun Apr  4 10:38:19 2010
@@ -31,7 +31,7 @@ under the License.
   <br />
   <div class="label">${uiLabelMap.ProductEditCategoryWithCategoryId}:</div>
   <form method="post" action="<@o...@ofbizUrl>" style="margin: 0;" name="EditCategoryForm">
-    <@formrenderer.renderLookupField name="productCategoryId" id="productCategoryId" formName="EditCategoryForm" fieldFormName="LookupProductCategory"/>
+    <@htmlTemplate.lookupField name="productCategoryId" id="productCategoryId" formName="EditCategoryForm" fieldFormName="LookupProductCategory"/>
     <input type="submit" value="${uiLabelMap.ProductEditCategory}" class="smallSubmit"/>
   </form>
   <br />
@@ -39,7 +39,7 @@ under the License.
   <br />
   <div class="label">${uiLabelMap.ProductEditProductWithProductId}:</div>
   <form method="post" action="<@o...@ofbizUrl>" style="margin: 0;" name="EditProductForm">
-    <@formrenderer.renderLookupField name="productId" id="productId" formName="EditProductForm" fieldFormName="LookupProduct"/>
+    <@htmlTemplate.lookupField name="productId" id="productId" formName="EditProductForm" fieldFormName="LookupProduct"/>
     <input type="submit" value=" ${uiLabelMap.ProductEditProduct}" class="smallSubmit"/>
   </form>
   <br />

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=930660&r1=930659&r2=930660&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Sun Apr  4 10:38:19 2010
@@ -1350,4 +1350,19 @@ public class UtilHttp {
             }
         }
     }
+
+    /**
+     * Returns a unique Id for the current request
+     * @param request An HttpServletRequest to get the name info from
+     * @return String
+     */
+    public static String getNextUniqueId(HttpServletRequest request) {
+        Integer uniqueIdNumber= (Integer)request.getAttribute("UNIQUE_ID");
+        if (uniqueIdNumber == null) {
+            uniqueIdNumber = Integer.valueOf(1);
+        }
+
+        request.setAttribute("UNIQUE_ID", Integer.valueOf(uniqueIdNumber.intValue() + 1));
+        return "autoId_" + uniqueIdNumber;
+    }
 }

Added: ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl?rev=930660&view=auto
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl (added)
+++ ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl Sun Apr  4 10:38:19 2010
@@ -0,0 +1,68 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<#include "component://widget/templates/htmlFormMacroLibrary.ftl"/>
+
+<#macro lookupField className="" alert="" name="" value="" size="20" maxlength="20" id="" event="" action="" disabled="" autocomplete="" descriptionFieldName="" formName="" fieldFormName="" targetParameterIter="" imgSrc="" ajaxUrl="" ajaxEnabled="" presentation="" width="20" height="20" position="20" fadeBackground="" clearText="">
+    <#if (!ajaxEnabled?has_content)>
+        <#assign javascriptEnabled = Static["org.ofbiz.base.util.UtilHttp"].isJavaScriptEnabled(request) />
+        <#if (javascriptEnabled)>
+            <#local ajaxEnabled = true>
+        </#if>
+    </#if>
+    <#if (!id?has_content)>
+        <#local id = Static["org.ofbiz.base.util.UtilHttp"].getNextUniqueId(request) />
+    </#if>
+    <#if (!ajaxUrl?has_content)>
+        <#local ajaxUrl = requestAttributes._REQUEST_HANDLER_.makeLink(request, response, fieldFormName)/>
+        <#local ajaxUrl = id + "," + ajaxUrl + ",ajaxLookup=Y&searchValueField=" + name />
+    </#if>
+    <@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 />
+</#macro>
+
+<#macro nextPrev commonUrl="" ajaxEnabled=false javaScriptEnabled=false paginateStyle="nav-pager" paginateFirstStyle="nav-first" viewIndex=0 highIndex=0 listSize=0 viewSize=1 ajaxFirstUrl="" firstUrl="" paginateFirstLabel="" paginatePreviousStyle="nav-previous" ajaxPreviousUrl="" previousUrl="" paginatePreviousLabel="" pageLabel="" ajaxSelectUrl="" selectUrl="" ajaxSelectSizeUrl="" selectSizeUrl="" commonDisplaying="" paginateNextStyle="nav-next" ajaxNextUrl="" nextUrl="" paginateNextLabel="" paginateLastStyle="nav-last" ajaxLastUrl="" lastUrl="" paginateLastLabel="" paginateViewSizeLabel="" >
+    <#local javaScriptEnabled = javaScriptEnabled />
+    <#if (!javaScriptEnabled)>
+        <#local javaScriptEnabled = Static["org.ofbiz.base.util.UtilHttp"].isJavaScriptEnabled(request) />
+    </#if>
+    <#if (commonUrl?has_content)>
+        <#if (!firstUr?has_content)>
+            <#local firstUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexFirst}"/>
+        </#if>
+        <#if (!previousUrl?has_content)>
+             <#local previousUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexPrevious}"/>
+        </#if>
+        <#if (!firstUr?has_content)>
+            <#local nextUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexNext}"/>
+        </#if>
+        <#if (!firstUr?has_content)>
+            <#local lastUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexLast}"/>
+        </#if>
+        <#if (!firstUr?has_content)>
+            <#local selectUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX="/>
+        </#if>
+        <#if (!firstUr?has_content)>
+            <#local selectSizeUrl=commonUrl+"VIEW_SIZE='+this.value+'&amp;VIEW_INDEX=0"/>
+        </#if>
+    </#if>
+    <#if (!commonDisplaying?has_content)>
+        <#local commonDisplaying="${lowIndex} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}"/>    
+    </#if>
+    <@renderNextPrev paginateStyle paginateFirstStyle viewIndex highIndex listSize viewSize ajaxEnabled javaScriptEnabled ajaxFirstUrl firstUrl paginateFirstLabel paginatePreviousStyle ajaxPreviousUrl previousUrl paginatePreviousLabel pageLabel ajaxSelectUrl selectUrl ajaxSelectSizeUrl selectSizeUrl commonDisplaying paginateNextStyle ajaxNextUrl nextUrl paginateNextLabel paginateLastStyle ajaxLastUrl lastUrl paginateLastLabel paginateViewSizeLabel />
+</#macro>
\ No newline at end of file

Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/common/webcommon/includes/htmlTemplate.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/framework/webtools/webapp/webtools/entity/ListGeneric.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/webapp/webtools/entity/ListGeneric.ftl?rev=930660&r1=930659&r2=930660&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/webapp/webtools/entity/ListGeneric.ftl (original)
+++ ofbiz/trunk/framework/webtools/webapp/webtools/entity/ListGeneric.ftl Sun Apr  4 10:38:19 2010
@@ -18,15 +18,7 @@ under the License.
 -->
         <#if (arraySize > 0)>
             <#assign commonUrl="FindGeneric?${curFindString}&amp;searchOptions_collapsed=${(parameters.searchOptions_collapsed)?default(\"false\")}&amp;"/>
-            <#assign firstUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexFirst}"/>
-            <#assign previousUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexPrevious}"/>
-            <#assign nextUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexNext}"/>
-            <#assign lastUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX=${viewIndexLast}"/>
-            <#assign selectUrl=commonUrl+"VIEW_SIZE=${viewSize}&amp;VIEW_INDEX="/>
-            <#assign selectSizeUrl=commonUrl+"VIEW_SIZE='+this.value+'&amp;VIEW_INDEX=0"/>
-            <#assign commonDisplaying="${uiLabelMap.CommonDisplaying} ${lowIndex} - ${highIndex} of ${arraySize}"/>        
-
-            <@formrenderer.renderNextPrev listSize=arraySize viewSize=viewSize viewIndex=viewIndex  highIndex=highIndex commonDisplaying=commonDisplaying firstUrl=firstUrl previousUrl=previousUrl nextUrl=nextUrl lastUrl=lastUrl selectUrl=selectUrl selectSizeUrl=selectSizeUrl/>
+            <@htmlTemplate.nextPrev commonUrl=commonUrl listSize=arraySize viewSize=viewSize viewIndex=viewIndex  highIndex=highIndex />
         </#if>
           <table class="basic-table hover-bar" cellspacing="0">
             <tr class="header-row-2">
@@ -60,5 +52,5 @@ under the License.
             </#if>
         </table>
         <#if (arraySize > 0)>
-            <@formrenderer.renderNextPrev listSize=arraySize viewSize=viewSize viewIndex=viewIndex  highIndex=highIndex commonDisplaying=commonDisplaying firstUrl=firstUrl previousUrl=previousUrl nextUrl=nextUrl lastUrl=lastUrl selectUrl=selectUrl selectSizeUrl=selectSizeUrl/>
+            <@htmlTemplate.nextPrev listSize=arraySize viewSize=viewSize viewIndex=viewIndex  highIndex=highIndex commonDisplaying=commonDisplaying firstUrl=firstUrl previousUrl=previousUrl nextUrl=nextUrl lastUrl=lastUrl selectUrl=selectUrl selectSizeUrl=selectSizeUrl/>
         </#if>

Modified: ofbiz/trunk/framework/widget/config/freemarkerImports.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/config/freemarkerImports.properties?rev=930660&r1=930659&r2=930660&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/config/freemarkerImports.properties (original)
+++ ofbiz/trunk/framework/widget/config/freemarkerImports.properties Sun Apr  4 10:38:19 2010
@@ -17,6 +17,4 @@
 # under the License.
 ###############################################################################
 
-screenrenderer=component://widget/templates/htmlScreenMacroLibrary.ftl
-formrenderer=component://widget/templates/htmlFormMacroLibrary.ftl
-treerenderer=component://widget/templates/htmlTreeMacroLibrary.ftl
+htmlTemplate=component://common/webcommon/includes/htmlTemplate.ftl

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=930660&r1=930659&r2=930660&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Sun Apr  4 10:38:19 2010
@@ -438,7 +438,7 @@ ${item.description}</div>
 </#if>
 </#macro>
 
-<#macro renderLookupField className="" alert="" name="" value="" size="20" maxlength="20" id="" event="" action="" disabled="" autocomplete="" descriptionFieldName="" formName="" fieldFormName="" targetParameterIter="" imgSrc="" ajaxUrl="" ajaxEnabled="" presentation="" width="20" height="20" position="20" fadeBackground="" clearText="">
+<#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>
 <div class="field-lookup"><ul>
 <#if size?has_content && size="0"><li><input type="hidden" <#if name?has_content> name="${name}"/></#if></li><#else><li><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/></li></#if>
 <li><#if presentation?has_content && descriptionFieldName?has_content && presentation == "layer">
@@ -465,7 +465,7 @@ ${item.description}</div>
 </#if>
 </#macro>
 
-<#macro renderNextPrev paginateStyle="nav-pager" paginateFirstStyle="nav-first" viewIndex=0 highIndex=0 listSize=0 viewSize=1 ajaxEnabled=false javaScriptEnabled=true ajaxFirstUrl="" firstUrl="" paginateFirstLabel="" paginatePreviousStyle="nav-previous" ajaxPreviousUrl="" previousUrl="" paginatePreviousLabel="" pageLabel="" ajaxSelectUrl="" selectUrl="" ajaxSelectSizeUrl="" selectSizeUrl="" commonDisplaying="" paginateNextStyle="nav-next" ajaxNextUrl="" nextUrl="" paginateNextLabel="" paginateLastStyle="nav-last" ajaxLastUrl="" lastUrl="" paginateLastLabel="" paginateViewSizeLabel="">
+<#macro renderNextPrev paginateStyle paginateFirstStyle viewIndex highIndex listSize viewSize ajaxEnabled javaScriptEnabled ajaxFirstUrl firstUrl paginateFirstLabel paginatePreviousStyle ajaxPreviousUrl previousUrl paginatePreviousLabel pageLabel ajaxSelectUrl selectUrl ajaxSelectSizeUrl selectSizeUrl commonDisplaying paginateNextStyle ajaxNextUrl nextUrl paginateNextLabel paginateLastStyle ajaxLastUrl lastUrl paginateLastLabel paginateViewSizeLabel>
 <#if listSize gt viewSize>
 <div class="${paginateStyle}">&nbsp; <ul>
 <li class="${paginateFirstStyle}<#if viewIndex gt 0>"><a href="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxFirstUrl}')<#else>${firstUrl}</#if>">${paginateFirstLabel}</a><#else>-disabled"><span>${paginateFirstLabel}</span></#if></li>