svn commit: r986577 - in /ofbiz/trunk: ./ applications/product/config/ applications/product/src/org/ofbiz/product/category/ framework/base/lib/ framework/widget/templates/

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

svn commit: r986577 - in /ofbiz/trunk: ./ applications/product/config/ applications/product/src/org/ofbiz/product/category/ framework/base/lib/ framework/widget/templates/

hansbak-2
Author: hansbak
Date: Wed Aug 18 06:33:12 2010
New Revision: 986577

URL: http://svn.apache.org/viewvc?rev=986577&view=rev
Log:
this is a revert of r731487 to downgrade freemarker from 2.3.15 to 2.3.10 because of speed problems. In order to make the older version work we changed the following:
- create new OfbizCatalogUrlTransform class
- delete CatalogUrlDirective.java class
- set ofbizCatalogUrl transform to OfbizCatalogUrlTransform class
- In htmlFormMacroLibrary.ftl file, change floor directive to floor method of Math class
- change freemarker version in .classpath and LICENSE files
We are in discussion with the freemarker developers to solve this problem there.

Added:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogUrlTransform.java
    ofbiz/trunk/framework/base/lib/freemarker-2.3.10.jar   (with props)
Removed:
    ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java
    ofbiz/trunk/framework/base/lib/freemarker-2.3.15.jar
Modified:
    ofbiz/trunk/.classpath
    ofbiz/trunk/LICENSE
    ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
    ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl

Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=986577&r1=986576&r2=986577&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Wed Aug 18 06:33:12 2010
@@ -18,7 +18,7 @@
     <classpathentry kind="lib" path="framework/base/lib/clhm-release-1.0-lru.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/hamcrest-all-1.2.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/fop-1.0.jar"/>
-    <classpathentry kind="lib" path="framework/base/lib/freemarker-2.3.15.jar"/>
+    <classpathentry kind="lib" path="framework/base/lib/freemarker-2.3.10.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/httpclient-4.0.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/httpcore-4.0.1.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/httpunit.jar"/>

Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=986577&r1=986576&r2=986577&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Wed Aug 18 06:33:12 2010
@@ -478,7 +478,7 @@ The JDOM License
 The following libraries distributed with Apache OFBiz are licensed under the
 BSD License:
 ofbiz/trunk/framework/base/lib/antisamy-bin.1.2.jar
-ofbiz/trunk/framework/base/lib/freemarker-2.3.15.jar
+ofbiz/trunk/framework/base/lib/freemarker-2.3.10.jar
 ofbiz/trunk/framework/base/lib/hamcrest-all-1.2.jar
 ofbiz/trunk/framework/base/lib/httpunit.jar
 ofbiz/trunk/framework/base/lib/ical4j-1.0-rc2.jar

Modified: ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/freemarkerTransforms.properties?rev=986577&r1=986576&r2=986577&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/config/freemarkerTransforms.properties (original)
+++ ofbiz/trunk/applications/product/config/freemarkerTransforms.properties Wed Aug 18 06:33:12 2010
@@ -21,4 +21,4 @@
 
 # entries are in the form: key=transform name, property=transform class name
 
-ofbizCatalogUrl=org.ofbiz.product.category.CatalogUrlDirective
+ofbizCatalogUrl=org.ofbiz.product.category.OfbizCatalogUrlTransform

Added: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogUrlTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogUrlTransform.java?rev=986577&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogUrlTransform.java (added)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/OfbizCatalogUrlTransform.java Wed Aug 18 06:33:12 2010
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.
+ *******************************************************************************/
+package org.ofbiz.product.category;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import freemarker.core.Environment;
+import freemarker.ext.beans.BeanModel;
+import freemarker.ext.beans.StringModel;
+import freemarker.template.SimpleScalar;
+import freemarker.template.TemplateModelException;
+import freemarker.template.TemplateTransformModel;
+
+public class OfbizCatalogUrlTransform implements TemplateTransformModel {
+    public final static String module = OfbizCatalogUrlTransform.class.getName();
+    
+    public String getStringArg(Map args, String key) {
+        Object o = args.get(key);
+        if (o instanceof SimpleScalar) {
+            return ((SimpleScalar) o).getAsString();
+        } else if (o instanceof StringModel) {
+            return ((StringModel) o).getAsString();
+        }
+        return null;
+    }
+
+    @Override
+    public Writer getWriter(final Writer out, final Map args)
+            throws TemplateModelException, IOException {
+        final StringBuilder buf = new StringBuilder();
+        return new Writer(out) {
+            
+            @Override
+            public void write(char[] cbuf, int off, int len) throws IOException {
+                buf.append(cbuf, off, len);
+            }
+            
+            @Override
+            public void flush() throws IOException {
+                out.flush();
+            }
+            
+            @Override
+            public void close() throws IOException {
+                try {
+                Environment env = Environment.getCurrentEnvironment();
+                BeanModel req = (BeanModel) env.getVariable("request");
+                if (req != null) {
+                    String productId = getStringArg(args, "productId");
+                    String currentCategoryId = getStringArg(args, "currentCategoryId");
+                    String previousCategoryId = getStringArg(args, "previousCategoryId");
+                    HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
+                    String catalogUrl = CatalogUrlServlet.makeCatalogUrl(request, productId, currentCategoryId, previousCategoryId);
+                    out.write(catalogUrl);
+                }
+                } catch (TemplateModelException e) {
+                    throw new IOException(e.getMessage());
+                }
+            }
+        };
+    }
+}
\ No newline at end of file

Added: ofbiz/trunk/framework/base/lib/freemarker-2.3.10.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/freemarker-2.3.10.jar?rev=986577&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/framework/base/lib/freemarker-2.3.10.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl?rev=986577&r1=986576&r2=986577&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl (original)
+++ ofbiz/trunk/framework/widget/templates/htmlFormMacroLibrary.ftl Wed Aug 18 06:33:12 2010
@@ -454,7 +454,7 @@ ${item.description}</span>
 <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>
 <li class="${paginatePreviousStyle}<#if viewIndex gt 0>"><a href="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxPreviousUrl}')<#else>${previousUrl}</#if>">${paginatePreviousLabel}</a><#else>-disabled"><span>${paginatePreviousLabel}</span></#if></li>
 <#if listSize gt 0 && javaScriptEnabled><li>${pageLabel}<select name="page" size="1" onchange="<#if ajaxEnabled>javascript:ajaxUpdateAreas('${ajaxSelectUrl}')<#else>location.href='${selectUrl}'+this.value;</#if>"><#rt/>
-<#assign x=listSize/viewSize?floor>
+<#assign x=Static["java.lang.Math"].floor(listSize/viewSize)>
 <#if listSize gt (viewIndex*viewSize)><#assign x=x+1></#if>
 <#list 1..x as i>
 <#if i == (viewIndex+1)><option selected="selected" value="<#else><option value="</#if>${i-1}">${i}</option>