ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adri...@apache.org
Subject svn commit: r607444 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
Date Sat, 29 Dec 2007 16:43:28 GMT
Author: adrianc
Date: Sat Dec 29 08:43:28 2007
New Revision: 607444

URL: http://svn.apache.org/viewvc?rev=607444&view=rev
Log:
Small enhancement to menu widget rendering to make it more compatible with other widgets.
Rendering of <a> elements is suppressed if no link target is specified. This will allow
the rendering of labels, captions, etc by using the <link> menu widget element without
the target attribute.

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

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=607444&r1=607443&r2=607444&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Sat Dec 29
08:43:28 2007
@@ -356,16 +356,21 @@
     }
 
     public void renderLink(StringBuffer buffer, Map context, ModelMenuItem.Link link) {
-        // open tag
-        buffer.append("<a");
-        String id = link.getId(context);
-        if (UtilValidate.isNotEmpty(id)) {
-            buffer.append(" id=\"");
-            buffer.append(id);
-            buffer.append("\"");
+        ModelMenuItem menuItem = link.getLinkMenuItem();
+        String target = link.getTarget(context);
+        if (menuItem.getDisabled()) {
+            target = null;
         }
+        if (UtilValidate.isNotEmpty(target)) {
+            // open tag
+            buffer.append("<a");
+            String id = link.getId(context);
+            if (UtilValidate.isNotEmpty(id)) {
+                buffer.append(" id=\"");
+                buffer.append(id);
+                buffer.append("\"");
+            }
         
-        ModelMenuItem menuItem = link.getLinkMenuItem();
 /*
         boolean isSelected = menuItem.isSelected(context);
         
@@ -392,22 +397,17 @@
         }
 */
         String name = link.getName(context);
-        if (UtilValidate.isNotEmpty(name)) {
-            buffer.append(" name=\"");
-            buffer.append(name);
-            buffer.append("\"");
-        }
-        String targetWindow = link.getTargetWindow(context);
-        if (UtilValidate.isNotEmpty(targetWindow)) {
-            buffer.append(" target=\"");
-            buffer.append(targetWindow);
-            buffer.append("\"");
-        }
-        String target = link.getTarget(context);
-        if (menuItem.getDisabled()) {
-            target = null;
-        }
-        if (UtilValidate.isNotEmpty(target)) {
+            if (UtilValidate.isNotEmpty(name)) {
+                buffer.append(" name=\"");
+                buffer.append(name);
+                buffer.append("\"");
+            }
+            String targetWindow = link.getTargetWindow(context);
+            if (UtilValidate.isNotEmpty(targetWindow)) {
+                buffer.append(" target=\"");
+                buffer.append(targetWindow);
+                buffer.append("\"");
+            }
             buffer.append(" href=\"");
             String urlMode = link.getUrlMode();
             String prefix = link.getPrefix(context);
@@ -427,7 +427,7 @@
                 } else {
                     buffer.append(target);
                 }
-            } else  if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
+            } else if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
                 StringBuffer newURL = new StringBuffer();
                 ContentUrlTag.appendContentPrefix(req, newURL);
                 newURL.append(target);
@@ -435,10 +435,8 @@
             } else {
                 buffer.append(target);
             }
-
-            buffer.append("\"");
+            buffer.append("\">");
         }
-        buffer.append(">");
         
         // the text
         Image img = link.getImage();
@@ -447,8 +445,10 @@
         else
             renderImage(buffer, context, img);
         
-        // close tag
-        buffer.append("</a>");
+        if (UtilValidate.isNotEmpty(target)) {
+            // close tag
+            buffer.append("</a>");
+        }
     }
 
     public void renderImage(StringBuffer buffer, Map context, ModelMenuItem.Image image)
{



Mime
View raw message