You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2010/06/21 10:04:53 UTC
svn commit: r956484 - in /ofbiz/trunk/applications/product:
config/freemarkerTransforms.properties
src/org/ofbiz/product/category/CatalogUrlDirective.java
Author: lektran
Date: Mon Jun 21 08:04:53 2010
New Revision: 956484
URL: http://svn.apache.org/viewvc?rev=956484&view=rev
Log:
Add a freemarker template directive (same as a transform) for making catalog urls i.e. same as StringUtil.wrapString(Static["org.ofbiz.product.category.CatalogUrlServlet"].makeCatalogUrl(...))
Can be accessed using <@ofbizCatalogUrl [productId=] [currentCategoryId=] [previousCategoryId=] />
Added:
ofbiz/trunk/applications/product/config/freemarkerTransforms.properties (with props)
ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java (with props)
Added: ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/freemarkerTransforms.properties?rev=956484&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/config/freemarkerTransforms.properties (added)
+++ ofbiz/trunk/applications/product/config/freemarkerTransforms.properties Mon Jun 21 08:04:53 2010
@@ -0,0 +1,24 @@
+###############################################################################
+# 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.
+###############################################################################
+### FreeMarker transforms ###
+#############################
+
+# entries are in the form: key=transform name, property=transform class name
+
+ofbizCatalogUrl=org.ofbiz.product.category.CatalogUrlDirective
Propchange: ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/trunk/applications/product/config/freemarkerTransforms.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java?rev=956484&view=auto
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java (added)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java Mon Jun 21 08:04:53 2010
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.ofbiz.base.util.UtilGenerics;
+
+
+import freemarker.core.Environment;
+import freemarker.ext.beans.BeanModel;
+import freemarker.template.TemplateDirectiveBody;
+import freemarker.template.TemplateDirectiveModel;
+import freemarker.template.TemplateException;
+import freemarker.template.TemplateModel;
+import freemarker.template.utility.DeepUnwrap;
+
+/**
+ * CatalogUrlDirective - Freemarker Template Directive for generating URLs suitable for use by the CatalogUrlServlet
+ *
+ * Accepts the following arguments (see CatalogUrlServlet for their definition):
+ * productId
+ * currentCategoryId
+ * previousCategoryId
+ *
+ */
+public class CatalogUrlDirective implements TemplateDirectiveModel {
+
+ public final static String module = CatalogUrlDirective.class.getName();
+
+ @Override
+ public void execute(Environment env, Map args, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
+ Map<String, TemplateModel> params = UtilGenerics.checkMap(args);
+ String productId = (String) DeepUnwrap.unwrap(params.get("productId"));
+ String currentCategoryId = (String) DeepUnwrap.unwrap(params.get("currentCategoryId"));
+ String previousCategoryId = (String) DeepUnwrap.unwrap(params.get("previousCategoryId"));
+
+ BeanModel req = (BeanModel) env.getVariable("request");
+
+ if (req != null) {
+ HttpServletRequest request = (HttpServletRequest) req.getWrappedObject();
+ env.getOut().write(CatalogUrlServlet.makeCatalogUrl(request, productId, currentCategoryId, previousCategoryId));
+ }
+ }
+}
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author URL Id"
Propchange: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CatalogUrlDirective.java
------------------------------------------------------------------------------
svn:mime-type = text/plain