svn commit: r1237309 - in /ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget: html/ menu/ screen/

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

svn commit: r1237309 - in /ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget: html/ menu/ screen/

adrianc
Author: adrianc
Date: Sun Jan 29 15:04:22 2012
New Revision: 1237309

URL: http://svn.apache.org/viewvc?rev=1237309&view=rev
Log:
Screen Widget Redesign - finished new menu renderer based on the MenuWidgetVisitor interface. Rendering code has been removed from the menu widget models.

Added:
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
      - copied, changed from r1236773, ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWidgetVisitor.java
Removed:
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWidgetVisitor.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java
Modified:
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java
    ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java

Copied: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (from r1236773, ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWidgetVisitor.java)
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?p2=ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java&p1=ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWidgetVisitor.java&r1=1236773&r2=1237309&rev=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWidgetVisitor.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Sun Jan 29 15:04:22 2012
@@ -21,6 +21,7 @@ package org.ofbiz.widget.html;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javax.servlet.ServletContext;
@@ -32,9 +33,11 @@ import org.ofbiz.base.util.GeneralExcept
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericValue;
 import org.ofbiz.webapp.control.RequestHandler;
 import org.ofbiz.webapp.taglib.ContentUrlTag;
 import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.PortalPageWorker;
 import org.ofbiz.widget.WidgetWorker;
 import org.ofbiz.widget.menu.MenuWidgetVisitor;
 import org.ofbiz.widget.menu.ModelMenu;
@@ -46,30 +49,38 @@ import org.ofbiz.widget.menu.ModelMenuIt
 /**
  * HTML menu widget renderer.
  */
-public final class HtmlMenuWidgetVisitor extends HtmlWidgetRenderer implements MenuWidgetVisitor {
+public final class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuWidgetVisitor {
 
     /**
      * Renders a <code>ModelMenu</code> as HTML.
+     *
      * @param modelMenu
      * @param writer
      * @param context
-     * @throws IllegalArgumentException if any arguments are <code>null</code> or if <code>modelMenu</code>
-     * is an unsupported type
+     * @throws IllegalArgumentException
+     *             if any arguments are <code>null</code> or if <code>modelMenu</code> is
+     *             an unsupported type
      * @throws IOException
      * @throws GeneralException
      */
     public static void render(ModelMenu modelMenu, Appendable writer, Map<String, Object> context) throws IOException, GeneralException {
         Assert.notNull("modelMenu", modelMenu);
-        if (!"simple".equals(modelMenu.getType())) {
-            throw new IllegalArgumentException("The type " + modelMenu.getType() + " is not supported for menu with name " + modelMenu.getName());
+        modelMenu.accept(new HtmlMenuRenderer(writer, context));
+    }
+
+    public static int renderedMenuItemCount(ModelMenu modelMenu, Map<String, Object> context) {
+        int count = 0;
+        for (ModelMenuItem item : modelMenu.getMenuItemList()) {
+            if (item.shouldBeRendered(context))
+                count++;
         }
-        modelMenu.accept(new HtmlMenuWidgetVisitor(writer, context));
+        return count;
     }
 
     private final Appendable writer;
     private final Map<String, Object> context;
 
-    public HtmlMenuWidgetVisitor(Appendable writer, Map<String, Object> context) {
+    public HtmlMenuRenderer(Appendable writer, Map<String, Object> context) {
         Assert.notNull("writer", writer, "context", context);
         this.writer = writer;
         this.context = context;
@@ -105,7 +116,7 @@ public final class HtmlMenuWidgetVisitor
         if (UtilValidate.isNotEmpty(fillStyle)) {
             writer.append("<div class=\"").append(fillStyle).append("\">&nbsp;</div>");
         }
-        if (modelMenu.renderedMenuItemCount(context) > 0) {
+        if (renderedMenuItemCount(modelMenu, context) > 0) {
             writer.append(" </ul>");
             appendWhitespace(writer);
             writer.append("</li>");
@@ -149,7 +160,7 @@ public final class HtmlMenuWidgetVisitor
             writer.append("<h2>").append(menuTitle).append("</h2>");
             appendWhitespace(writer);
         }
-        if (modelMenu.renderedMenuItemCount(context) > 0) {
+        if (renderedMenuItemCount(modelMenu, context) > 0) {
             writer.append("<ul>");
             appendWhitespace(writer);
             writer.append("<li>");
@@ -209,7 +220,7 @@ public final class HtmlMenuWidgetVisitor
                 } else {
                     writer.append(src);
                 }
-            } else  if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
+            } else if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
                 if (request != null && response != null) {
                     StringBuilder newURL = new StringBuilder();
                     ContentUrlTag.appendContentPrefix(request, newURL);
@@ -234,14 +245,16 @@ public final class HtmlMenuWidgetVisitor
             HttpServletResponse response = (HttpServletResponse) context.get("response");
             HttpServletRequest request = (HttpServletRequest) context.get("request");
             String targetWindow = link.getTargetWindow(context);
-            String uniqueItemName = menuItem.getModelMenu().getName() + "_" + menuItem.getName() + "_LF_" + UtilMisc.<String>addToBigDecimalInMap(context, "menuUniqueItemIndex", BigDecimal.ONE);
+            String uniqueItemName = menuItem.getModelMenu().getName() + "_" + menuItem.getName() + "_LF_"
+                    + UtilMisc.<String> addToBigDecimalInMap(context, "menuUniqueItemIndex", BigDecimal.ONE);
             String linkType = WidgetWorker.determineAutoLinkType(link.getLinkType(), target, link.getUrlMode(), request);
             if ("hidden-form".equals(linkType)) {
                 writer.append("<form method=\"post\"");
                 writer.append(" action=\"");
-                // note that this passes null for the parameterList on purpose so they won't be put into the URL
-                WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context),
-                        link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
+                // note that this passes null for the parameterList on purpose so they
+                // won't be put into the URL
+                WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context), link.getFullPath(), link.getSecure(), link
+                        .getEncode(), request, response, context);
                 writer.append("\"");
                 if (UtilValidate.isNotEmpty(targetWindow)) {
                     writer.append(" target=\"");
@@ -252,7 +265,7 @@ public final class HtmlMenuWidgetVisitor
                 writer.append(uniqueItemName);
                 writer.append("\">");
                 StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
-                for (Map.Entry<String, String> parameter: link.getParameterMap(context).entrySet()) {
+                for (Map.Entry<String, String> parameter : link.getParameterMap(context).entrySet()) {
                     writer.append("<input name=\"");
                     writer.append(parameter.getKey());
                     writer.append("\" value=\"");
@@ -309,12 +322,12 @@ public final class HtmlMenuWidgetVisitor
                     writer.append("javascript:confirmActionLink('");
                     writer.append(confirmationMsg);
                     writer.append("', '");
-                    WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterMap(context), link.getPrefix(context),
-                            link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
+                    WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterMap(context), link.getPrefix(context), link
+                            .getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
                     writer.append("')");
                 } else {
-                WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterMap(context), link.getPrefix(context),
-                        link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
+                    WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterMap(context), link.getPrefix(context), link
+                            .getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
                 }
             }
             writer.append("\">");
@@ -332,6 +345,9 @@ public final class HtmlMenuWidgetVisitor
     }
 
     public void visit(ModelMenu modelMenu) throws IOException, GeneralException {
+        if (!"simple".equals(modelMenu.getType())) {
+            throw new IllegalArgumentException("The type " + modelMenu.getType() + " is not supported for menu with name " + modelMenu.getName());
+        }
         ModelMenuAction.runSubActions(modelMenu.getActions(), this.context);
         renderMenuOpen(writer, context, modelMenu);
         for (ModelMenuItem item : modelMenu.getMenuItemList()) {
@@ -341,9 +357,37 @@ public final class HtmlMenuWidgetVisitor
     }
 
     public void visit(ModelMenuItem modelMenuItem) throws IOException, GeneralException {
-        if (isHideIfSelected(modelMenuItem)) {
+        if (isHideIfSelected(modelMenuItem) || !modelMenuItem.evaluateConditions(context)) {
             return;
         }
+        Locale locale = (Locale) context.get("locale");
+        ModelMenuAction.runSubActions(modelMenuItem.getActions(), context);
+        String parentPortalPageId = modelMenuItem.getParentPortalPageId(context);
+        if (UtilValidate.isNotEmpty(parentPortalPageId)) {
+            List<GenericValue> portalPages = PortalPageWorker.getPortalPages(parentPortalPageId, context);
+            if (UtilValidate.isNotEmpty(portalPages)) {
+                for (GenericValue portalPage : portalPages) {
+                    if (UtilValidate.isNotEmpty(portalPage.getString("portalPageName"))) {
+                        ModelMenuItem localItem = new ModelMenuItem(modelMenuItem.getModelMenu());
+                        localItem.setName(portalPage.getString("portalPageId"));
+                        localItem.setTitle((String) portalPage.get("portalPageName", locale));
+                        localItem.setLink(new Link(modelMenuItem));
+                        List<WidgetWorker.Parameter> linkParams = localItem.getLink().getParameterList();
+                        linkParams.add(new WidgetWorker.Parameter("portalPageId", portalPage.getString("portalPageId"), false));
+                        linkParams.add(new WidgetWorker.Parameter("parentPortalPageId", parentPortalPageId, false));
+                        if (modelMenuItem.getLink() != null) {
+                            localItem.getLink().setTarget(modelMenuItem.getLink().getTarget());
+                            linkParams.addAll(modelMenuItem.getLink().getParameterList());
+                        } else {
+                            localItem.getLink().setTarget("showPortalPage");
+                        }
+                        localItem.getLink().setText((String)portalPage.get("portalPageName", locale));
+                        localItem.accept(this);
+                    }
+                }
+                return;
+            }
+        }
         String style = modelMenuItem.getWidgetStyle();
         if (modelMenuItem.isSelected(context)) {
             style = modelMenuItem.getSelectedStyle();

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Sun Jan 29 15:04:22 2012
@@ -50,7 +50,9 @@ import org.ofbiz.widget.WidgetWorker;
 import org.ofbiz.widget.form.FormStringRenderer;
 import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.menu.MenuStringRenderer;
-import org.ofbiz.widget.menu.ModelMenu;
+import org.ofbiz.widget.menu.*;
+import org.ofbiz.widget.menu.ModelMenuAction;
+import org.ofbiz.widget.menu.ModelMenuItem;
 import org.ofbiz.widget.screen.ModelScreenWidget;
 import org.ofbiz.widget.screen.ScreenStringRenderer;
 
@@ -224,11 +226,20 @@ public class HtmlScreenRenderer extends
             }
             if (!collapsed) {
                 if (navMenu != null) {
-                    MenuStringRenderer savedRenderer = (MenuStringRenderer) context.get("menuStringRenderer");
-                    MenuStringRenderer renderer = new ScreenletMenuRenderer(request, response);
-                    context.put("menuStringRenderer", renderer);
-                    navMenu.renderWidgetString(writer, context, this);
-                    context.put("menuStringRenderer", savedRenderer);
+                    MenuWidgetVisitor htmlMenuRenderer = (MenuWidgetVisitor) context.get("htmlMenuRenderer");
+                    if (htmlMenuRenderer == null) {
+                        htmlMenuRenderer = new HtmlMenuRenderer(writer, context);
+                        context.put("htmlMenuRenderer", htmlMenuRenderer);
+                    }
+                    org.ofbiz.widget.menu.ModelMenu modelMenu = navMenu.getModelMenu(context);
+                    ModelMenuAction.runSubActions(modelMenu.getActions(), context);
+                    for (ModelMenuItem item : modelMenu.getMenuItemList()) {
+                        try {
+                            item.accept(htmlMenuRenderer);
+                        } catch (GeneralException e) {
+                            throw new IOException(e);
+                        }
+                    }
                 } else if (navForm != null) {
                     renderScreenletPaginateMenu(writer, context, navForm);
                 }
@@ -423,16 +434,6 @@ public class HtmlScreenRenderer extends
         appendWhitespace(writer);
     }
 
-    public static class ScreenletMenuRenderer extends HtmlMenuRenderer {
-        public ScreenletMenuRenderer(HttpServletRequest request, HttpServletResponse response) {
-            super(request, response);
-        }
-        @Override
-        public void renderMenuOpen(Appendable writer, Map<String, Object> context, ModelMenu modelMenu) {}
-        @Override
-        public void renderMenuClose(Appendable writer, Map<String, Object> context, ModelMenu modelMenu) {}
-    }
-
     public void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label) throws IOException {
         String labelText = label.getText(context);
         if (UtilValidate.isEmpty(labelText)) {

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java Sun Jan 29 15:04:22 2012
@@ -31,13 +31,14 @@ import javax.servlet.http.HttpSession;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilGenerics;
+import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.template.FreeMarkerWorker;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.webapp.ftl.LoopWriter;
 import org.ofbiz.widget.WidgetContentWorker;
-import org.ofbiz.widget.html.HtmlMenuWrapper;
+import org.ofbiz.widget.html.HtmlMenuRenderer;
 
 import freemarker.core.Environment;
 import freemarker.template.TemplateModelException;
@@ -70,6 +71,8 @@ public class MenuWrapTransform implement
     public static final String [] upSaveKeyNames = {"globalNodeTrail"};
     public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale",  "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "renderOnStart", "renderOnClose", "menuDefFile", "menuName", "associatedContentId", "wrapperClassName"};
 
+    // TODO: This class does not appear to be used anywhere
+
     @SuppressWarnings("unchecked")
     public Writer getWriter(final Writer out, Map args) {
         final Environment env = Environment.getCurrentEnvironment();
@@ -177,22 +180,44 @@ public class MenuWrapTransform implement
             }
 
             public void renderMenu() throws IOException {
-
-                String menuDefFile = (String)templateCtx.get("menuDefFile");
-                String menuName = (String)templateCtx.get("menuName");
-                String menuWrapperClassName = (String)templateCtx.get("menuWrapperClassName");
-                HtmlMenuWrapper menuWrapper = HtmlMenuWrapper.getMenuWrapper(request, response, session, menuDefFile, menuName, menuWrapperClassName);
-
-                if (menuWrapper == null) {
-                    throw new IOException("HtmlMenuWrapper with def file:" + menuDefFile + " menuName:" + menuName + " and HtmlMenuWrapper class:" + menuWrapperClassName + " could not be instantiated.");
+                String location = (String)templateCtx.get("menuDefFile");
+                String name = (String)templateCtx.get("menuName");
+                ModelMenu modelMenu = null;
+                try {
+                    modelMenu = MenuFactory.getMenuFromLocation(location, name);
+                } catch (Exception e) {
+                    String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: ";
+                    Debug.logError(e, errMsg, module);
+                    throw new IOException(errMsg + e);
                 }
-
                 String associatedContentId = (String)templateCtx.get("associatedContentId");
-                menuWrapper.putInContext("defaultAssociatedContentId", associatedContentId);
-                menuWrapper.putInContext("currentValue", view);
-
-                String menuStr = menuWrapper.renderMenuString();
-                out.write(menuStr);
+                Map<String, Object> context = createContext();
+                context.put("defaultAssociatedContentId", associatedContentId);
+                context.put("currentValue", view);
+                try {
+                    HtmlMenuRenderer.render(modelMenu, out, context);
+                } catch (GeneralException e) {
+                    throw new IOException(e);
+                }
+            }
+            
+            private Map<String, Object> createContext() {
+                Map<String, Object> context = new HashMap<String, Object>();
+                Map<String, Object> parameterMap = UtilHttp.getParameterMap(request);
+                context.put("parameters", parameterMap);
+                HttpSession session = request.getSession();
+                GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
+                context.put("userLogin", userLogin);
+                context.put("locale", UtilHttp.getLocale(request));
+                if (UtilValidate.isNotEmpty(request.getAttribute("_ERROR_MESSAGE_"))) {
+                    context.put("isError", Boolean.TRUE);
+                } else {
+                    context.put("isError", Boolean.FALSE);
+                }
+                if ("true".equals(parameterMap.get("isError"))) {
+                    context.put("isError", Boolean.TRUE);
+                }
+                return context;
             }
 
         };

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Sun Jan 29 15:04:22 2012
@@ -295,72 +295,7 @@ public class ModelMenu extends ModelWidg
         }
             return existingMenuItem;
     }
-
-    /**
-     * Renders this menu to a String, i.e. in a text format, as defined with the
-     * MenuStringRenderer implementation.
-     *
-     * @param writer The Writer that the menu text will be written to
-     * @param context Map containing the menu context; the following are
-     *   reserved words in this context: parameters (Map), isError (Boolean),
-     *   itemIndex (Integer, for lists only, otherwise null), bshInterpreter,
-     *   menuName (String, optional alternate name for menu, defaults to the
-     *   value of the name attribute)
-     * @param menuStringRenderer An implementation of the MenuStringRenderer
-     *   interface that is responsible for the actual text generation for
-     *   different menu elements; implementing you own makes it possible to
-     *   use the same menu definitions for many types of menu UIs
-     */
-    public void renderMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
-
-        boolean passed = true;
-
-            //Debug.logInfo("in ModelMenu, name:" + this.getName(), module);
-        if (passed) {
-            ModelMenuAction.runSubActions(this.actions, context);
-            if ("simple".equals(this.type)) {
-                this.renderSimpleMenuString(writer, context, menuStringRenderer);
-            } else {
-                throw new IllegalArgumentException("The type " + this.getType() + " is not supported for menu with name " + this.getName());
-            }
-        }
-            //Debug.logInfo("in ModelMenu, buffer:" + buffer.toString(), module);
-    }
-
-    public int renderedMenuItemCount(Map<String, Object> context)
-    {
-        int count = 0;    
-        for (ModelMenuItem item : this.menuItemList) {
-            if (item.shouldBeRendered(context))
-             count++;        
-        }
-        return count;
-    }
     
-    public void renderSimpleMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
-        //Iterator menuItemIter = null;
-        //Set alreadyRendered = new TreeSet();
-
-        // render menu open
-        menuStringRenderer.renderMenuOpen(writer, context, this);
-
-        // render formatting wrapper open
-        menuStringRenderer.renderFormatSimpleWrapperOpen(writer, context, this);
-
-        //Debug.logInfo("in ModelMenu, menuItemList:" + menuItemList, module);
-        // render each menuItem row, except hidden & ignored rows
-        // include portal pages if specified
-        //menuStringRenderer.renderFormatSimpleWrapperRows(writer, context, this);
-        for (ModelMenuItem item : this.menuItemList) {
-                item.renderMenuItemString(writer, context, menuStringRenderer);
-        }
-        // render formatting wrapper close
-        menuStringRenderer.renderFormatSimpleWrapperClose(writer, context, this);
-
-        // render menu close
-        menuStringRenderer.renderMenuClose(writer, context, this);
-    }
-
     /**
      * @deprecated Use getDispatcher(Map<String, Object>) instead, this method will throw an {@link UnsupportedOperationException} if used
      */

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Sun Jan 29 15:04:22 2012
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import javax.xml.parsers.ParserConfigurationException;
@@ -39,10 +38,8 @@ import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
-import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entityext.permission.EntityPermissionChecker;
 import org.ofbiz.widget.WidgetWorker;
-import org.ofbiz.widget.PortalPageWorker;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
@@ -270,49 +267,6 @@ public class ModelMenuItem {
         return passed;
     }
     
-    public void renderMenuItemString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
-
-        boolean passed = true;
-        if (this.condition != null) {
-            if (!this.condition.eval(context)) {
-                passed = false;
-            }
-        }
-        Locale locale = (Locale) context.get("locale");
-           //Debug.logInfo("in ModelMenu, name:" + this.getName(), module);
-        if (passed) {
-            ModelMenuAction.runSubActions(this.actions, context);
-            String parentPortalPageId = this.getParentPortalPageId(context);
-            if (UtilValidate.isNotEmpty(parentPortalPageId)) {
-                List<GenericValue> portalPages = PortalPageWorker.getPortalPages(parentPortalPageId, context);
-                if (UtilValidate.isNotEmpty(portalPages)) {
-                    for (GenericValue portalPage : portalPages) {
-                        if (UtilValidate.isNotEmpty(portalPage.getString("portalPageName"))) {
-                            ModelMenuItem localItem = new ModelMenuItem(this.getModelMenu());
-                            localItem.name =  portalPage.getString("portalPageId");
-                            localItem.setTitle((String) portalPage.get("portalPageName", locale));
-                            localItem.link = new Link(this);
-                            List<WidgetWorker.Parameter> linkParams = localItem.link.getParameterList();
-                            linkParams.add(new WidgetWorker.Parameter("portalPageId", portalPage.getString("portalPageId"), false));
-                            linkParams.add(new WidgetWorker.Parameter("parentPortalPageId", parentPortalPageId, false));
-                            if (link != null) {
-                                localItem.link.setTarget(link.targetExdr.getOriginal());
-                                linkParams.addAll(link.parameterList);
-                            } else {
-                                localItem.link.setTarget("showPortalPage");
-                            }
-                            localItem.link.setText((String)portalPage.get("portalPageName", locale));
-                            menuStringRenderer.renderMenuItem(writer, context, localItem);
-                        }
-                    }
-                }
-            } else {
-                menuStringRenderer.renderMenuItem(writer, context, this);
-            }
-        }
-    }
-
-
     public ModelMenu getModelMenu() {
         return modelMenu;
     }
@@ -405,7 +359,7 @@ public class ModelMenuItem {
     }
 
     public String getParentPortalPageId(Map<String, Object> context) {
-        return this.parentPortalPageId.expandString(context);
+        return this.parentPortalPageId == null ? null : this.parentPortalPageId.expandString(context);
     }
 
     public String getWidgetStyle() {
@@ -824,6 +778,10 @@ public class ModelMenuItem {
             return linkMenuItem;
         }
 
+        public String getTarget() {
+            return this.targetExdr.getOriginal();
+        }
+
     }
 
     public static class Image {
@@ -917,4 +875,15 @@ public class ModelMenuItem {
         }
 
     }
+
+    public boolean evaluateConditions(Map<String, Object> context) {
+        if (this.condition != null) {
+            return this.condition.eval(context);
+        }
+        return true;
+    }
+
+    public void setLink(Link link) {
+        this.link = link;
+    }
 }

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Sun Jan 29 15:04:22 2012
@@ -55,8 +55,11 @@ import org.ofbiz.widget.WidgetWorker;
 import org.ofbiz.widget.form.FormStringRenderer;
 import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.html.HtmlFormRenderer;
-import org.ofbiz.widget.html.HtmlScreenRenderer.ScreenletMenuRenderer;
+import org.ofbiz.widget.html.HtmlMenuRenderer;
 import org.ofbiz.widget.menu.MenuStringRenderer;
+import org.ofbiz.widget.menu.MenuWidgetVisitor;
+import org.ofbiz.widget.menu.ModelMenuAction;
+import org.ofbiz.widget.menu.ModelMenuItem;
 import org.ofbiz.widget.screen.ModelScreenWidget;
 import org.ofbiz.widget.screen.ScreenStringRenderer;
 
@@ -615,11 +618,21 @@ public class MacroScreenRenderer impleme
             }
             StringWriter sb = new StringWriter();
             if (navMenu != null) {
-                MenuStringRenderer savedRenderer = (MenuStringRenderer) context.get("menuStringRenderer");
-                MenuStringRenderer renderer = new ScreenletMenuRenderer(request, response);
-                context.put("menuStringRenderer", renderer);
-                navMenu.renderWidgetString(sb, context, this);
-                context.put("menuStringRenderer", savedRenderer);
+                MenuWidgetVisitor macroMenuRenderer = (MenuWidgetVisitor) context.get("macroMenuRenderer");
+                if (macroMenuRenderer == null) {
+                    // TODO: Implement macro renderer
+                    macroMenuRenderer = new HtmlMenuRenderer(sb, context);
+                    context.put("macroMenuRenderer", macroMenuRenderer);
+                }
+                org.ofbiz.widget.menu.ModelMenu modelMenu = navMenu.getModelMenu(context);
+                ModelMenuAction.runSubActions(modelMenu.getActions(), context);
+                for (ModelMenuItem item : modelMenu.getMenuItemList()) {
+                    try {
+                        item.accept(macroMenuRenderer);
+                    } catch (GeneralException e) {
+                        throw new IOException(e);
+                    }
+                }
             } else if (navForm != null) {
                 renderScreenletPaginateMenu(sb, context, navForm);
             }

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java Sun Jan 29 15:04:22 2012
@@ -98,7 +98,6 @@ public class MacroScreenViewHandler exte
             // this is the object used to render forms from their definitions
             screens.getContext().put("formStringRenderer", formStringRenderer);
             screens.getContext().put("treeStringRenderer", treeStringRenderer);
-            //screens.getContext().put("menuStringRenderer", menuStringRenderer);
             screens.getContext().put("simpleEncoder", StringUtil.getEncoder(UtilProperties.getPropertyValue("widget", getName() + ".encoder")));
             screenStringRenderer.renderScreenBegin(writer, screens.getContext());
             screens.render(page);

Modified: ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=1237309&r1=1237308&r2=1237309&view=diff
==============================================================================
--- ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original)
+++ ofbiz/branches/20111115ScreenWidgetRedesign/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Sun Jan 29 15:04:22 2012
@@ -55,10 +55,11 @@ import org.ofbiz.widget.form.FormFactory
 import org.ofbiz.widget.form.FormStringRenderer;
 import org.ofbiz.widget.form.ModelForm;
 import org.ofbiz.widget.html.HtmlFormRenderer;
-import org.ofbiz.widget.html.HtmlMenuWidgetVisitor;
+import org.ofbiz.widget.html.HtmlMenuRenderer;
 import org.ofbiz.widget.menu.MenuFactory;
-import org.ofbiz.widget.menu.MenuStringRenderer;
+import org.ofbiz.widget.menu.MenuWidgetVisitor;
 import org.ofbiz.widget.menu.ModelMenu;
+import org.ofbiz.widget.menu.ModelMenuAction;
 import org.ofbiz.widget.tree.ModelTree;
 import org.ofbiz.widget.tree.TreeFactory;
 import org.ofbiz.widget.tree.TreeStringRenderer;
@@ -1313,18 +1314,15 @@ public abstract class ModelScreenWidget
         @Override
         public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws IOException {
             ModelMenu modelMenu = getModelMenu(context);
-            // try finding the menuStringRenderer by name in the context in case one was prepared and put there
-            MenuStringRenderer menuStringRenderer = (MenuStringRenderer) context.get("menuStringRenderer");
-            // if there was no menuStringRenderer put in place, now try finding the request/response in the context and creating a new one
+            MenuWidgetVisitor menuStringRenderer = (MenuWidgetVisitor) context.get("menuStringRenderer");
             if (menuStringRenderer == null) {
-                try {
-                    modelMenu.accept(new HtmlMenuWidgetVisitor(writer, context));
-                } catch (GeneralException e) {
-                    throw new IOException(e);
-                }
-                return;
+                menuStringRenderer = new HtmlMenuRenderer(writer, context);
+            }
+            try {
+                modelMenu.accept(new HtmlMenuRenderer(writer, context));
+            } catch (GeneralException e) {
+                throw new IOException(e);
             }
-            throw new IllegalArgumentException("Could not find a menuStringRenderer in the context, and could not find HTTP request/response objects need to create one.");
         }
 
         public ModelMenu getModelMenu(Map<String, Object> context) {
@@ -1353,6 +1351,10 @@ public abstract class ModelScreenWidget
         public String rawString() {
             return "<include-menu name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\"/>";
         }
+
+        public List<ModelMenuAction> getActions(Map<String, Object> context) {
+            return getModelMenu(context).getActions();
+        }
     }
 
     public static class Link extends ModelScreenWidget {