Author: lektran
Date: Thu Apr 8 23:14:07 2010 New Revision: 932170 URL: http://svn.apache.org/viewvc?rev=932170&view=rev Log: Applied patch from Jacopo Cappellato, switched the content rendering logic over to using the macro renderers rather than the soon to be deprecated html renderers Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java?rev=932170&r1=932169&r2=932170&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/cms/CmsEvents.java Thu Apr 8 23:14:07 2010 @@ -39,6 +39,7 @@ import org.ofbiz.base.util.GeneralRuntim import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilJ2eeCompat; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.MapStack; import org.ofbiz.content.content.ContentWorker; @@ -49,9 +50,12 @@ import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.website.WebSiteWorker; -import org.ofbiz.widget.html.HtmlFormRenderer; +import org.ofbiz.widget.form.FormStringRenderer; +import org.ofbiz.widget.form.MacroFormRenderer; import org.ofbiz.widget.screen.ScreenRenderer; +import freemarker.template.TemplateException; + /** * CmsEvents @@ -249,7 +253,6 @@ public class CmsEvents { // create the template map MapStack<String> templateMap = MapStack.create(); ScreenRenderer.populateContextForRequest(templateMap, null, request, response, servletContext); - templateMap.put("formStringRenderer", new HtmlFormRenderer(request, response)); templateMap.put("statusCode", statusCode); // make the link prefix @@ -276,7 +279,9 @@ public class CmsEvents { } else { writer = response.getWriter(); } - + // TODO: replace "screen" to support dynamic rendering of different output + FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", "screen.formrenderer"), writer, request, response); + templateMap.put("formStringRenderer", formStringRenderer); // render if (UtilValidate.isEmpty(mapKey)) { ContentWorker.renderContentAsText(dispatcher, delegator, contentId, writer, templateMap, locale, "text/html", null, null, true); @@ -284,6 +289,8 @@ public class CmsEvents { ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, writer, mapKey, templateMap, locale, "text/html", true); } + } catch (TemplateException e) { + throw new GeneralRuntimeException("Error creating form renderer", e); } catch (IOException e) { throw new GeneralRuntimeException("Error in the response writer/output stream: " + e.toString(), e); } catch (GeneralException e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=932170&r1=932169&r2=932170&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Thu Apr 8 23:14:07 2010 @@ -70,7 +70,7 @@ import org.ofbiz.entity.GenericEntityExc import org.ofbiz.entity.GenericValue; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; -import org.ofbiz.widget.html.HtmlScreenRenderer; +import org.ofbiz.widget.screen.MacroScreenRenderer; import org.ofbiz.widget.screen.ModelScreen; import org.ofbiz.widget.screen.ScreenFactory; import org.ofbiz.widget.screen.ScreenRenderer; @@ -690,7 +690,9 @@ public class DataResourceWorker impleme // get the screen renderer; or create a new one ScreenRenderer screens = (ScreenRenderer) context.get("screens"); if (screens == null) { - screens = new ScreenRenderer(out, context, new HtmlScreenRenderer()); + // TODO: replace "screen" to support dynamic rendering of different output + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", "screen.name"), UtilProperties.getPropertyValue("widget", "screen.screenrenderer"), out); + screens = new ScreenRenderer(out, context, screenStringRenderer); screens.getContext().put("screens", screens); } // render the screen @@ -716,6 +718,8 @@ public class DataResourceWorker impleme throw new GeneralException("Error rendering Screen template", e); } catch (ParserConfigurationException e) { throw new GeneralException("Error rendering Screen template", e); + } catch (TemplateException e) { + throw new GeneralException("Error creating Screen renderer", e); } } else { throw new GeneralException("The dataTemplateTypeId [" + dataTemplateTypeId + "] is not yet supported"); |
Free forum by Nabble | Edit this page |