svn commit: r684051 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

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

svn commit: r684051 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

adrianc
Author: adrianc
Date: Fri Aug  8 11:49:33 2008
New Revision: 684051

URL: http://svn.apache.org/viewvc?rev=684051&view=rev
Log:
Small fix for HtmlScreenRenderer.java - don't render an img element if there is no image to display.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java

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?rev=684051&r1=684050&r2=684051&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Fri Aug  8 11:49:33 2008
@@ -533,6 +533,10 @@
 
     public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.Image image) throws IOException {
         // open tag
+        String src = image.getSrc(context);
+        if (UtilValidate.isEmpty(src)) {
+            return;
+        }
         writer.append("<img ");
         String id = image.getId(context);
         if (UtilValidate.isNotEmpty(id)) {
@@ -564,39 +568,34 @@
             writer.append(border);
             writer.append("\"");
         }
-        String src = image.getSrc(context);
-        if (UtilValidate.isNotEmpty(src)) {
-            writer.append(" src=\"");
-            String urlMode = image.getUrlMode();
-            boolean fullPath = false;
-            boolean secure = false;
-            boolean encode = false;
-            HttpServletResponse response = (HttpServletResponse) context.get("response");
-            HttpServletRequest request = (HttpServletRequest) context.get("request");
-            if (urlMode != null && urlMode.equalsIgnoreCase("intra-app")) {
-                if (request != null && response != null) {
-                    ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
-                    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
-                    String urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
-                    writer.append(urlString);
-                } else {
-                    writer.append(src);
-                }
-            } else  if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
-                if (request != null && response != null) {
-                    StringBuffer newURL = new StringBuffer();
-                    ContentUrlTag.appendContentPrefix(request, newURL);
-                    newURL.append(src);
-                    writer.append(newURL.toString());
-                }
+        writer.append(" src=\"");
+        String urlMode = image.getUrlMode();
+        boolean fullPath = false;
+        boolean secure = false;
+        boolean encode = false;
+        HttpServletResponse response = (HttpServletResponse) context.get("response");
+        HttpServletRequest request = (HttpServletRequest) context.get("request");
+        if (urlMode != null && urlMode.equalsIgnoreCase("intra-app")) {
+            if (request != null && response != null) {
+                ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
+                RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+                String urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
+                writer.append(urlString);
             } else {
                 writer.append(src);
             }
-
-            writer.append("\"");
+        } else  if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
+            if (request != null && response != null) {
+                StringBuffer newURL = new StringBuffer();
+                ContentUrlTag.appendContentPrefix(request, newURL);
+                newURL.append(src);
+                writer.append(newURL.toString());
+            }
+        } else {
+            writer.append(src);
         }
-        writer.append("/>");
         
+        writer.append("\"/>");
         
         appendWhitespace(writer);
     }