Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java Thu Mar 8 11:46:09 2007 @@ -42,6 +42,7 @@ import org.ofbiz.entity.model.ModelEntity; import org.ofbiz.entity.model.ModelUtil; import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.service.LocalDispatcher; /** * Product Content Worker: gets product content to display @@ -56,36 +57,40 @@ public static ProductContentWrapper makeProductContentWrapper(GenericValue product, HttpServletRequest request) { return new ProductContentWrapper(product, request); } - + + LocalDispatcher dispatcher; protected GenericValue product; protected Locale locale; protected String mimeTypeId; - public ProductContentWrapper(GenericValue product, Locale locale, String mimeTypeId) { + public ProductContentWrapper(LocalDispatcher dispatcher, GenericValue product, Locale locale, String mimeTypeId) { + this.dispatcher = dispatcher; this.product = product; this.locale = locale; this.mimeTypeId = mimeTypeId; } public ProductContentWrapper(GenericValue product, HttpServletRequest request) { + this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); this.product = product; this.locale = UtilHttp.getLocale(request); this.mimeTypeId = "text/html"; } public String get(String productContentTypeId) { - return getProductContentAsText(product, productContentTypeId, locale, mimeTypeId, product.getDelegator()); + return getProductContentAsText(product, productContentTypeId, locale, mimeTypeId, product.getDelegator(), dispatcher); } public static String getProductContentAsText(GenericValue product, String productContentTypeId, HttpServletRequest request) { - return getProductContentAsText(product, productContentTypeId, UtilHttp.getLocale(request), "text/html", product.getDelegator()); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + return getProductContentAsText(product, productContentTypeId, UtilHttp.getLocale(request), "text/html", product.getDelegator(), dispatcher); } - public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale) { - return getProductContentAsText(product, productContentTypeId, locale, null, null); + public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, LocalDispatcher dispatcher) { + return getProductContentAsText(product, productContentTypeId, locale, null, null, dispatcher); } - public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator) { + public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) { if (product == null) { return null; } @@ -101,7 +106,7 @@ } Writer outWriter = new StringWriter(); - getProductContentAsText(null, product, productContentTypeId, locale, mimeTypeId, delegator, outWriter); + getProductContentAsText(null, product, productContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter); String outString = outWriter.toString(); if (outString.length() > 0) { if (productContentCache != null) { @@ -123,7 +128,7 @@ } } - public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, Writer outWriter) throws GeneralException, IOException { + public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { if (productId == null && product != null) { productId = product.getString("productId"); } @@ -163,7 +168,7 @@ Map inContext = new HashMap(); inContext.put("product", product); inContext.put("productContent", productContent); - ContentWorker.renderContentAsText(delegator, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); + ContentWorker.renderContentAsText(dispatcher, delegator, productContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); } } } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Thu Mar 8 11:46:09 2007 @@ -814,9 +814,9 @@ StringBuffer ppBuf = new StringBuffer(); ppBuf.append(UtilProperties.getMessage(resource, "ProductCategory", locale)+": "); if (productCategory != null) { - String catInfo = CategoryContentWrapper.getProductCategoryContentAsText(productCategory, "CATEGORY_NAME", locale); + String catInfo = CategoryContentWrapper.getProductCategoryContentAsText(productCategory, "CATEGORY_NAME", locale, null); if (UtilValidate.isEmpty(catInfo)) { - catInfo = CategoryContentWrapper.getProductCategoryContentAsText(productCategory, "DESCRIPTION", locale); + catInfo = CategoryContentWrapper.getProductCategoryContentAsText(productCategory, "DESCRIPTION", locale, null); } ppBuf.append(catInfo); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Thu Mar 8 11:46:09 2007 @@ -299,7 +299,7 @@ * Get the name to show to the customer for GWP alternative options. * If the alternative is a variant, find the distinguishing features and show those instead of the name; if it is not a variant then show the PRODUCT_NAME content. */ - public static String getGwpAlternativeOptionName(GenericDelegator delegator, String alternativeOptionProductId, Locale locale) { + public static String getGwpAlternativeOptionName(LocalDispatcher dispatcher, GenericDelegator delegator, String alternativeOptionProductId, Locale locale) { try { GenericValue alternativeOptionProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", alternativeOptionProductId)); if (alternativeOptionProduct != null) { @@ -327,7 +327,7 @@ } // got to here, default to PRODUCT_NAME - String alternativeProductName = ProductContentWrapper.getProductContentAsText(alternativeOptionProduct, "PRODUCT_NAME", locale); + String alternativeProductName = ProductContentWrapper.getProductContentAsText(alternativeOptionProduct, "PRODUCT_NAME", locale, dispatcher); // Debug.logInfo("Using PRODUCT_NAME: " + alternativeProductName, module); return alternativeProductName; } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/shipment/thirdparty/dhl/DhlServices.java Thu Mar 8 11:46:09 2007 @@ -80,7 +80,7 @@ /** * Opens a URL to DHL and makes a request. * - * @param dhlService + * @param xmlString * Name of the DHL service to invoke * @param xmlString * XML message to send @@ -247,7 +247,7 @@ inContext.put("postalCode", shipToAddress.getString("postalCode")); } try { - ContentWorker.renderContentAsText(delegator, templateName, outWriter, inContext, locale, "text/plain", false); + ContentWorker.renderContentAsText(dispatcher, delegator, templateName, outWriter, inContext, locale, "text/plain", false); } catch (Exception e) { Debug.logError(e, "Cannot get DHL Estimate: Failed to render DHL XML Request.", module); return ServiceUtil.returnError("Cannot get DHL Estimate: Failed to render DHL XML Request."); @@ -725,7 +725,7 @@ inContext.put("shipperReference", shipment.getString("primaryOrderId") + "-" + shipment.getString("primaryShipGroupSeqId")); try { - ContentWorker.renderContentAsText(delegator, templateName, outWriter, inContext, locale, "text/plain", false); + ContentWorker.renderContentAsText(dispatcher, delegator, templateName, outWriter, inContext, locale, "text/plain", false); } catch (Exception e) { Debug.logError(e, "Cannot confirm DHL shipment: Failed to render DHL XML Request.", module); return ServiceUtil.returnError("Cannot confirm DHL shipment: Failed to render DHL XML Request."); Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java (original) +++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java Thu Mar 8 11:46:09 2007 @@ -39,6 +39,7 @@ import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.cache.UtilCache; +import org.ofbiz.service.LocalDispatcher; import javolution.util.FastMap; import javolution.util.FastList; @@ -52,11 +53,13 @@ public static UtilCache workEffortContentCache = new UtilCache("workeffort.content.rendered", true); + protected LocalDispatcher dispatcher; protected GenericValue workEffort; protected Locale locale; protected String mimeTypeId; - public WorkEffortContentWrapper(GenericValue workEffort, Locale locale, String mimeTypeId) { + public WorkEffortContentWrapper(LocalDispatcher dispatcher, GenericValue workEffort, Locale locale, String mimeTypeId) { + this.dispatcher = dispatcher; this.workEffort = workEffort; this.locale = locale; this.mimeTypeId = mimeTypeId; @@ -70,7 +73,7 @@ // interface implementation(s) public String get(String workEffortContentId, boolean useCache) { - return getWorkEffortContentAsText(workEffort, workEffortContentId, locale, mimeTypeId, workEffort.getDelegator(), useCache); + return getWorkEffortContentAsText(workEffort, workEffortContentId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, useCache); } /** @@ -163,7 +166,7 @@ public List getList(String contentTypeId) { try { - return getWorkEffortContentTextList(workEffort, contentTypeId, locale, mimeTypeId, workEffort.getDelegator()); + return getWorkEffortContentTextList(workEffort, contentTypeId, locale, mimeTypeId, workEffort.getDelegator(), dispatcher); } catch (Exception e) { Debug.logError(e, module); return null; @@ -193,7 +196,7 @@ } public String getContent(String contentId, boolean useCache) { - return getWorkEffortContentAsText(workEffort, contentId, null, locale, mimeTypeId, workEffort.getDelegator(), useCache); + return getWorkEffortContentAsText(workEffort, contentId, null, locale, mimeTypeId, workEffort.getDelegator(), dispatcher, useCache); } public String getContent(String contentId) { @@ -202,20 +205,21 @@ // static method helpers public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, HttpServletRequest request) { - return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, UtilHttp.getLocale(request), "text/html", workEffort.getDelegator(), true); + LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); + return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, UtilHttp.getLocale(request), "text/html", workEffort.getDelegator(), dispatcher, true); } - public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, Locale locale) { - return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, locale, null, null, true); + public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, Locale locale, LocalDispatcher dispatcher) { + return getWorkEffortContentAsText(workEffort, workEffortContentTypeId, locale, null, null, dispatcher, true); } public static String getWorkEffortContentAsText(GenericValue workEffort, String workEffortContentTypeId, - Locale locale, String mimeTypeId, GenericDelegator delegator, boolean useCache) { - return getWorkEffortContentAsText(workEffort, null, workEffortContentTypeId, locale, mimeTypeId, delegator, useCache); + Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, boolean useCache) { + return getWorkEffortContentAsText(workEffort, null, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, useCache); } public static String getWorkEffortContentAsText(GenericValue workEffort, String contentId, String workEffortContentTypeId, - Locale locale, String mimeTypeId, GenericDelegator delegator, boolean useCache) { + Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, boolean useCache) { if (workEffort == null) { return null; } @@ -236,7 +240,7 @@ } Writer outWriter = new StringWriter(); - getWorkEffortContentAsText(contentId, null, workEffort, workEffortContentTypeId, locale, mimeTypeId, delegator, outWriter); + getWorkEffortContentAsText(contentId, null, workEffort, workEffortContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter); String outString = outWriter.toString(); if (outString.length() > 0) { if (workEffortContentCache != null) { @@ -258,7 +262,7 @@ } } - public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, Writer outWriter) throws GeneralException, IOException { + public static void getWorkEffortContentAsText(String contentId, String workEffortId, GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException { if (workEffortId == null && workEffort != null) { workEffortId = workEffort.getString("workEffortId"); } @@ -303,11 +307,11 @@ Map inContext = FastMap.newInstance(); inContext.put("workEffort", workEffort); inContext.put("workEffortContent", workEffortContent); - ContentWorker.renderContentAsText(delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); + ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); } } - public static List getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator) throws GeneralException, IOException { + public static List getWorkEffortContentTextList(GenericValue workEffort, String workEffortContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) throws GeneralException, IOException { List partyContentList = delegator.findByAndCache("WorkEffortContent", UtilMisc.toMap("workEffortId", workEffort.getString("partyId"), "workEffortContentTypeId", workEffortContentTypeId), UtilMisc.toList("-fromDate")); partyContentList = EntityUtil.filterByDate(partyContentList); @@ -320,7 +324,7 @@ Map inContext = FastMap.newInstance(); inContext.put("workEffort", workEffort); inContext.put("workEffortContent", workEffortContent); - ContentWorker.renderContentAsText(delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); + ContentWorker.renderContentAsText(dispatcher, delegator, workEffortContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); contentList.add(outWriter.toString()); } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java Thu Mar 8 11:46:09 2007 @@ -28,6 +28,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.LocalDispatcher; /** * ContentWorkerInterface @@ -40,9 +41,9 @@ public String getMimeTypeIdExt(GenericDelegator delegator, GenericValue view, Map ctx); // new rendering methods - public void renderContentAsTextExt(GenericDelegator delegator, String contentId, Writer out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; - public String renderContentAsTextExt(GenericDelegator delegator, String contentId, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public void renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public String renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; - public void renderSubContentAsTextExt(GenericDelegator delegator, String contentId, Writer out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; - public String renderSubContentAsTextExt(GenericDelegator delegator, String contentId, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public String renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?view=diff&rev=516158&r1=516157&r2=516158 ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Thu Mar 8 11:46:09 2007 @@ -40,6 +40,7 @@ import org.ofbiz.widget.WidgetContentWorker; import org.ofbiz.widget.screen.ModelScreenWidget; import org.ofbiz.widget.screen.ScreenStringRenderer; +import org.ofbiz.service.LocalDispatcher; import javolution.util.FastMap; /** @@ -287,6 +288,7 @@ String mimeTypeId = "text/html"; String expandedContentId = content.getContentId(context); String renderedContent = null; + LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); GenericDelegator delegator = (GenericDelegator) context.get("delegator"); // make a new map for content rendering; so our current map does not get clobbered @@ -298,7 +300,7 @@ try { if (UtilValidate.isNotEmpty(expandedContentId)) { if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderContentAsTextExt(delegator, expandedContentId, contentContext, locale, mimeTypeId, true); + renderedContent = WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, expandedContentId, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } @@ -307,7 +309,7 @@ String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); } @@ -410,6 +412,7 @@ String expandedContentId = content.getContentId(context); String expandedMapKey = content.getMapKey(context); String renderedContent = null; + LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); GenericDelegator delegator = (GenericDelegator) context.get("delegator"); // create a new map for the content rendering; so our current context does not get overwritten! @@ -418,7 +421,7 @@ try { if (WidgetContentWorker.contentWorker != null) { - renderedContent = WidgetContentWorker.contentWorker.renderSubContentAsTextExt(delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); + renderedContent = WidgetContentWorker.contentWorker.renderSubContentAsTextExt(dispatcher, delegator, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); //Debug.logInfo("renderedContent=" + renderedContent, module); } else { Debug.logError("Not rendering content, not ContentWorker found.", module); @@ -427,7 +430,7 @@ String editRequest = content.getEditRequest(context); if (UtilValidate.isNotEmpty(editRequest)) { if (WidgetContentWorker.contentWorker != null) { - WidgetContentWorker.contentWorker.renderContentAsTextExt(delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); + WidgetContentWorker.contentWorker.renderContentAsTextExt(dispatcher, delegator, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); } else { Debug.logError("Not rendering content, ContentWorker not found.", module); } |
Free forum by Nabble | Edit this page |