Re: svn commit: r564975 - /ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

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

Re: svn commit: r564975 - /ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

Jacques Le Roux
Administrator
Commiters, All,

Sorry, I forgot to temporarily revert my Eclipse "no useless blanks everywhere"' setting. By chance this one is easy to read (which
means the file was nearly clean ;o)

Jacques

> Author: jleroux
> Date: Sat Aug 11 14:04:22 2007
> New Revision: 564975
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=564975
> Log:
> A patch from Adrian Crum "Improved template rendering error message" (https://issues.apache.org/jira/browse/OFBIZ-1188)
> Done by hand
>
> Modified:
>     ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
>
> Modified: ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
> URL:
http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java?view=diff&rev=564975&r1=564974&r2=564975

> ==============================================================================
> --- ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java (original)
> +++ ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java Sat Aug 11 14:04:22 2007
> @@ -6,9 +6,9 @@
>   * 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
> @@ -28,6 +28,7 @@
>
>  import org.ofbiz.base.util.Debug;
>  import org.ofbiz.base.util.GeneralException;
> +import org.ofbiz.base.util.UtilValidate;
>  import org.ofbiz.base.util.UtilXml;
>  import org.ofbiz.base.util.collections.MapStack;
>  import org.ofbiz.base.util.string.FlexibleStringExpander;
> @@ -41,9 +42,9 @@
>   */
>  public class HtmlWidget extends ModelScreenWidget {
>      public static final String module = HtmlWidget.class.getName();
> -
> +
>      protected ModelScreenWidget childWidget;
> -
> +
>      public HtmlWidget(ModelScreen modelScreen, Element htmlElement) {
>          super(modelScreen, htmlElement);
>          List childElementList = UtilXml.childElementList(htmlElement);
> @@ -67,11 +68,15 @@
>      public String rawString() {
>          return "<html-widget>" + (this.childWidget==null?"":this.childWidget.rawString());
>      }
> -
> +
>      public static void renderHtmlTemplate(Writer writer, FlexibleStringExpander locationExdr, Map context) {
>          String location = locationExdr.expandString(context);
>          //Debug.logInfo("Rendering template at location [" + location + "] with context: \n" + context, module);
> -
> +
> +        if (UtilValidate.isEmpty(location)) {
> +            throw new IllegalArgumentException("Template location is empty");
> +        }
> +
>          if (location.endsWith(".ftl")) {
>              try {
>                  FreeMarkerWorker.renderTemplateAtLocation(location, context, writer);
> @@ -89,13 +94,13 @@
>                  throw new RuntimeException(errMsg);
>              }
>          } else {
> -            throw new IllegalArgumentException("Rending not yet support for the tempalte at location: " + location);
> +            throw new IllegalArgumentException("Rendering not yet supported for the template at location: " + location);
>          }
>      }
> -
> +
>      public static class HtmlTemplate extends ModelScreenWidget {
>          protected FlexibleStringExpander locationExdr;
> -
> +
>          public HtmlTemplate(ModelScreen modelScreen, Element htmlTemplateElement) {
>              super(modelScreen, htmlTemplateElement);
>              this.locationExdr = new FlexibleStringExpander(htmlTemplateElement.getAttribute("location"));
> @@ -113,11 +118,11 @@
>      public static class HtmlTemplateDecorator extends ModelScreenWidget {
>          protected FlexibleStringExpander locationExdr;
>          protected Map sectionMap = new HashMap();
> -
> +
>          public HtmlTemplateDecorator(ModelScreen modelScreen, Element htmlTemplateDecoratorElement) {
>              super(modelScreen, htmlTemplateDecoratorElement);
>              this.locationExdr = new FlexibleStringExpander(htmlTemplateDecoratorElement.getAttribute("location"));
> -
> +
>              List htmlTemplateDecoratorSectionElementList = UtilXml.childElementList(htmlTemplateDecoratorElement,
"html-template-decorator-section");

>              Iterator htmlTemplateDecoratorSectionElementIter = htmlTemplateDecoratorSectionElementList.iterator();
>              while (htmlTemplateDecoratorSectionElementIter.hasNext()) {
> @@ -139,7 +144,7 @@
>              MapStack standAloneStack = contextMs.standAloneChildStack();
>              standAloneStack.put("screens", new ScreenRenderer(writer, standAloneStack, screenStringRenderer));
>              SectionsRenderer sections = new SectionsRenderer(this.sectionMap, standAloneStack, writer, screenStringRenderer);
> -
> +
>              // put the sectionMap in the context, make sure it is in the sub-scope, ie after calling push on the MapStack
>              contextMs.push();
>              context.put("sections", sections);
> @@ -155,7 +160,7 @@
>      public static class HtmlTemplateDecoratorSection extends ModelScreenWidget {
>          protected String name;
>          protected List subWidgets;
> -
> +
>          public HtmlTemplateDecoratorSection(ModelScreen modelScreen, Element htmlTemplateDecoratorSectionElement) {
>              super(modelScreen, htmlTemplateDecoratorSectionElement);
>              this.name = htmlTemplateDecoratorSectionElement.getAttribute("name");
>