svn commit: r1649482 [18/26] - in /ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./ applications/accounting/src/org/ofbiz/accounting/invoice/ applications/accounting/src/org/ofbiz/accounting/payment/ applications/accounting/src/org/ofbiz/ac...

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

svn commit: r1649482 [18/26] - in /ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23: ./ applications/accounting/src/org/ofbiz/accounting/invoice/ applications/accounting/src/org/ofbiz/accounting/payment/ applications/accounting/src/org/ofbiz/ac...

jleroux@apache.org
Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Mon Jan  5 08:50:30 2015
@@ -31,8 +31,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.StringUtil;
-import org.ofbiz.base.util.StringUtil.SimpleEncoder;
+import org.ofbiz.base.util.UtilCodec;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
@@ -90,7 +89,7 @@ public class HtmlFormRenderer extends Ht
     protected String lastFieldGroupId = "";
     protected boolean renderPagination = true;
     protected boolean javaScriptEnabled = false;
-    private SimpleEncoder internalEncoder;
+    private UtilCodec.SimpleEncoder internalEncoder;
 
     protected HtmlFormRenderer() {}
 
@@ -100,7 +99,7 @@ public class HtmlFormRenderer extends Ht
         ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
         this.rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
         this.javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request);
-        internalEncoder = StringUtil.getEncoder("string");
+        internalEncoder = UtilCodec.getEncoder("string");
     }
 
     public boolean getRenderPagination() {
@@ -362,7 +361,7 @@ public class HtmlFormRenderer extends Ht
         if (UtilValidate.isEmpty(value)) {
             return value;
         }
-        StringUtil.SimpleEncoder encoder = (StringUtil.SimpleEncoder)context.get("simpleEncoder");
+        UtilCodec.SimpleEncoder encoder = (UtilCodec.SimpleEncoder)context.get("simpleEncoder");
         if (modelFormField.getEncodeOutput() && encoder != null) {
             value = encoder.encode(value);
         } else {

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Mon Jan  5 08:50:30 2015
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletRes
 import javax.servlet.http.HttpSession;
 
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilCodec;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
@@ -157,7 +158,7 @@ public class HtmlMenuRenderer extends Ht
             }
         }
 
-        if (menuItem.getDisabled() || this.isDisableIfEmpty(menuItem, context)) {
+        if (this.isDisableIfEmpty(menuItem, context)) {
             style = menuItem.getDisabledTitleStyle();
         }
 
@@ -185,7 +186,7 @@ public class HtmlMenuRenderer extends Ht
             renderLink(writer, context, link);
         } else {
             String txt = menuItem.getTitle(context);
-            StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
+            UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
             if (simpleEncoder != null) {
                 txt = simpleEncoder.encode(txt);
             }
@@ -377,7 +378,7 @@ public class HtmlMenuRenderer extends Ht
     public void renderLink(Appendable writer, Map<String, Object> context, ModelMenuItem.Link link) throws IOException {
         String target = link.getTarget(context);
         ModelMenuItem menuItem = link.getLinkMenuItem();
-        if (menuItem.getDisabled() || isDisableIfEmpty(menuItem, context)) {
+        if (isDisableIfEmpty(menuItem, context)) {
             target = null;
         }
 
@@ -407,7 +408,7 @@ public class HtmlMenuRenderer extends Ht
                 writer.append(uniqueItemName);
                 writer.append("\">");
 
-                StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
+                UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
                 for (Map.Entry<String, String> parameter: link.getParameterMap(context).entrySet()) {
                     writer.append("<input name=\"");
                     writer.append(parameter.getKey());

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Mon Jan  5 08:50:30 2015
@@ -61,7 +61,7 @@ public class HtmlTreeRenderer extends Ht
         appendWhitespace(writer);
         writer.append("<li>");
 
-        String pkName = node.getPkName();
+        String pkName = node.getPkName(context);
         String entityId = null;
         String entryName = node.getEntryName();
         if (UtilValidate.isNotEmpty(entryName)) {
@@ -71,7 +71,6 @@ public class HtmlTreeRenderer extends Ht
         }
         boolean hasChildren = node.hasChildren(context);
 
-        ModelTree.ModelNode.Link expandCollapseLink = new ModelTree.ModelNode.Link();
         // check to see if this node needs to be expanded.
         if (hasChildren && node.isExpandCollapse()) {
             String targetEntityId = null;
@@ -79,7 +78,8 @@ public class HtmlTreeRenderer extends Ht
             if (depth < targetNodeTrail.size()) {
                 targetEntityId = targetNodeTrail.get(depth);
             }
-
+            // FIXME: Using a widget model in this way is an ugly hack.
+            ModelTree.ModelNode.Link expandCollapseLink = null;
             int openDepth = node.getModelTree().getOpenDepth();
             if (depth >= openDepth && (targetEntityId == null || !targetEntityId.equals(entityId))) {
                 // Not on the trail
@@ -87,8 +87,6 @@ public class HtmlTreeRenderer extends Ht
                     context.put("processChildren", Boolean.FALSE);
                     //expandCollapseLink.setText("&nbsp;+&nbsp;");
                     currentNodeTrailPiped = StringUtil.join(currentNodeTrail, "|");
-                    expandCollapseLink.setStyle("collapsed");
-                    expandCollapseLink.setText(" ");
                     StringBuilder target = new StringBuilder(node.getModelTree().getExpandCollapseRequest(context));
                     String trailName = node.getModelTree().getTrailName(context);
                     if (target.indexOf("?") < 0) {
@@ -97,7 +95,7 @@ public class HtmlTreeRenderer extends Ht
                         target.append("&");
                     }
                     target.append(trailName).append("=").append(currentNodeTrailPiped);
-                    expandCollapseLink.setTarget(target.toString());
+                    expandCollapseLink = new ModelTree.ModelNode.Link("collapsed", target.toString(), " ");
                 }
             } else {
                 context.put("processChildren", Boolean.TRUE);
@@ -107,8 +105,6 @@ public class HtmlTreeRenderer extends Ht
                 if (currentNodeTrailPiped == null) {
                     currentNodeTrailPiped = "";
                 }
-                expandCollapseLink.setStyle("expanded");
-                expandCollapseLink.setText(" ");
                 StringBuilder target = new StringBuilder(node.getModelTree().getExpandCollapseRequest(context));
                 String trailName = node.getModelTree().getTrailName(context);
                 if (target.indexOf("?") < 0) {
@@ -117,15 +113,16 @@ public class HtmlTreeRenderer extends Ht
                     target.append("&");
                 }
                 target.append(trailName).append("=").append(currentNodeTrailPiped);
-                expandCollapseLink.setTarget(target.toString());
+                expandCollapseLink = new ModelTree.ModelNode.Link("expanded", target.toString(), " ");
                 // add it so it can be remove in renderNodeEnd
                 currentNodeTrail.add(lastContentId);
             }
-            renderLink(writer, context, expandCollapseLink);
+            if (expandCollapseLink != null) {
+                renderLink(writer, context, expandCollapseLink);
+            }
         } else if (!hasChildren) {
             context.put("processChildren", Boolean.FALSE);
-            expandCollapseLink.setStyle("leafnode");
-            expandCollapseLink.setText(" ");
+            ModelTree.ModelNode.Link expandCollapseLink = new ModelTree.ModelNode.Link("leafnode", "", " ");
             renderLink(writer, context, expandCollapseLink);
         }
     }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java Mon Jan  5 08:50:30 2015
@@ -33,6 +33,7 @@ import javax.servlet.http.HttpServletRes
 
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.UtilCodec;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.template.FreeMarkerWorker;
@@ -193,7 +194,7 @@ public class MacroMenuRenderer implement
         Map<String, Object> parameters = new HashMap<String, Object>();
         String target = link.getTarget(context);
         ModelMenuItem menuItem = link.getLinkMenuItem();
-        if (menuItem.getDisabled() || isDisableIfEmpty(menuItem, context)) {
+        if (isDisableIfEmpty(menuItem, context)) {
             target = null;
         }
         parameters.put("id", link.getId(context));
@@ -289,7 +290,7 @@ public class MacroMenuRenderer implement
                 style = "selected";
             }
         }
-        if (menuItem.getDisabled() || this.isDisableIfEmpty(menuItem, context)) {
+        if (this.isDisableIfEmpty(menuItem, context)) {
             style = menuItem.getDisabledTitleStyle();
         }
         if (style == null) {
@@ -309,7 +310,7 @@ public class MacroMenuRenderer implement
             linkStr = sw.toString();
         } else {
             linkStr = menuItem.getTitle(context);
-            StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
+            UtilCodec.SimpleEncoder simpleEncoder = (UtilCodec.SimpleEncoder) context.get("simpleEncoder");
             if (simpleEncoder != null) {
                 linkStr = simpleEncoder.encode(linkStr);
             }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java Mon Jan  5 08:50:30 2015
@@ -84,8 +84,7 @@ public class MenuFactory {
             // read document and construct ModelMenu for each menu element
             Element rootElement = menuFileDoc.getDocumentElement();
             for (Element menuElement: UtilXml.childElementList(rootElement, "menu")){
-                ModelMenu modelMenu = new ModelMenu(menuElement);
-                modelMenu.setMenuLocation(menuLocation);
+                ModelMenu modelMenu = new ModelMenu(menuElement, menuLocation);
                 modelMenuMap.put(modelMenu.getName(), modelMenu);
             }
          }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Mon Jan  5 08:50:30 2015
@@ -20,6 +20,7 @@ package org.ofbiz.widget.menu;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,34 +36,50 @@ import org.ofbiz.widget.ModelWidgetVisit
 import org.w3c.dom.Element;
 
 /**
- * Widget Library - Menu model class
+ * Models the &lt;menu&gt; element.
+ *
+ * @see <code>widget-menu.xsd</code>
  */
 @SuppressWarnings("serial")
 public class ModelMenu extends ModelWidget {
 
+    /*
+     * ----------------------------------------------------------------------- *
+     *                     DEVELOPERS PLEASE READ
+     * ----------------------------------------------------------------------- *
+     *
+     * This model is intended to be a read-only data structure that represents
+     * an XML element. Outside of object construction, the class should not
+     * have any behaviors.
+     *
+     * Instances of this class will be shared by multiple threads - therefore
+     * it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME!
+     *
+     */
+
     public static final String module = ModelMenu.class.getName();
 
-    protected List<ModelWidgetAction> actions;
-    protected String defaultAlign;
-    protected String defaultAlignStyle;
-    protected FlexibleStringExpander defaultAssociatedContentId;
-    protected String defaultCellWidth;
-    protected String defaultDisabledTitleStyle;
-    protected String defaultEntityName;
-    protected Boolean defaultHideIfSelected;
-    protected String defaultMenuItemName;
-    protected String defaultPermissionEntityAction;
-    protected String defaultPermissionOperation;
-    protected String defaultPermissionStatusId;
-    protected String defaultPrivilegeEnumId;
-    protected String defaultSelectedStyle;
-    protected String defaultTitleStyle;
-    protected String defaultTooltipStyle;
-    protected String defaultWidgetStyle;
-    protected FlexibleStringExpander extraIndex;
-    protected String fillStyle;
-    protected String id;
-    protected FlexibleStringExpander menuContainerStyleExdr;
+    private final List<ModelWidgetAction> actions;
+    private final String defaultAlign;
+    private final String defaultAlignStyle;
+    private final FlexibleStringExpander defaultAssociatedContentId;
+    private final String defaultCellWidth;
+    private final String defaultDisabledTitleStyle;
+    private final String defaultEntityName;
+    private final Boolean defaultHideIfSelected;
+    private final String defaultMenuItemName;
+    private final String defaultPermissionEntityAction;
+    private final String defaultPermissionOperation;
+    private final String defaultPermissionStatusId;
+    private final String defaultPrivilegeEnumId;
+    private final String defaultSelectedStyle;
+    private final String defaultTitleStyle;
+    private final String defaultTooltipStyle;
+    private final String defaultWidgetStyle;
+    private final FlexibleStringExpander extraIndex;
+    private final String fillStyle;
+    private final String id;
+    private final FlexibleStringExpander menuContainerStyleExdr;
     /** This List will contain one copy of each item for each item name in the order
      * they were encountered in the service, entity, or menu definition; item definitions
      * with constraints will also be in this list but may appear multiple times for the same
@@ -72,41 +89,68 @@ public class ModelMenu extends ModelWidg
      * necessary to use the Map. The Map is used when loading the menu definition to keep the
      * list clean and implement the override features for item definitions.
      */
-    protected List<ModelMenuItem> menuItemList = new ArrayList<ModelMenuItem>();
+    private final List<ModelMenuItem> menuItemList;
     /** This Map is keyed with the item name and has a ModelMenuItem for the value; items
      * with conditions will not be put in this Map so item definition overrides for items
      * with conditions is not possible.
      */
-    protected Map<String, ModelMenuItem> menuItemMap = new HashMap<String, ModelMenuItem>();
-    protected String menuLocation;
-    protected String menuWidth;
-    protected String orientation = "horizontal";
-    protected FlexibleMapAccessor<String> selectedMenuItemContextFieldName;
-    protected String target;
-    protected FlexibleStringExpander title;
-    protected String tooltip;
-    protected String type;
-
-
-   // ===== CONSTRUCTORS =====
+    private final Map<String, ModelMenuItem> menuItemMap;
+    private final String menuLocation;
+    private final String menuWidth;
+    private final String orientation;
+    private final FlexibleMapAccessor<String> selectedMenuItemContextFieldName;
+    private final String target;
+    private final FlexibleStringExpander title;
+    private final String tooltip;
+    private final String type;
 
     /** XML Constructor */
-    public ModelMenu(Element menuElement) {
+    public ModelMenu(Element menuElement, String menuLocation) {
         super(menuElement);
-
+        ArrayList<ModelWidgetAction> actions = new ArrayList<ModelWidgetAction>();
+        String defaultAlign = "";
+        String defaultAlignStyle = "";
+        FlexibleStringExpander defaultAssociatedContentId = FlexibleStringExpander.getInstance("");
+        String defaultCellWidth = "";
+        String defaultDisabledTitleStyle = "";
+        String defaultEntityName = "";
+        Boolean defaultHideIfSelected = Boolean.FALSE;
+        String defaultMenuItemName = "";
+        String defaultPermissionEntityAction = "";
+        String defaultPermissionOperation = "";
+        String defaultPermissionStatusId = "";
+        String defaultPrivilegeEnumId = "";
+        String defaultSelectedStyle = "";
+        String defaultTitleStyle = "";
+        String defaultTooltipStyle = "";
+        String defaultWidgetStyle = "";
+        FlexibleStringExpander extraIndex = FlexibleStringExpander.getInstance("");
+        String fillStyle = "";
+        String id = "";
+        FlexibleStringExpander menuContainerStyleExdr = FlexibleStringExpander.getInstance("");
+        ArrayList<ModelMenuItem> menuItemList = new ArrayList<ModelMenuItem>();
+        Map<String, ModelMenuItem> menuItemMap = new HashMap<String, ModelMenuItem>();
+        String menuWidth = "";
+        String orientation = "horizontal";
+        FlexibleMapAccessor<String> selectedMenuItemContextFieldName = FlexibleMapAccessor.getInstance("");
+        String target = "";
+        FlexibleStringExpander title = FlexibleStringExpander.getInstance("");
+        String tooltip = "";
+        String type = "";
         // check if there is a parent menu to inherit from
         String parentResource = menuElement.getAttribute("extends-resource");
         String parentMenu = menuElement.getAttribute("extends");
-        if (parentMenu.length() > 0 && !(parentMenu.equals(menuElement.getAttribute("name")) && UtilValidate.isEmpty(parentResource))) {
+        if (!parentMenu.isEmpty()) {
             ModelMenu parent = null;
-            // check if we have a resource name (part of the string before the ?)
-            if (UtilValidate.isNotEmpty(parentResource)) {
+            if (!parentResource.isEmpty()) {
                 try {
                     parent = MenuFactory.getMenuFromLocation(parentResource, parentMenu);
                 } catch (Exception e) {
-                    Debug.logError(e, "Failed to load parent menu definition '" + parentMenu + "' at resource '" + parentResource + "'", module);
+                    Debug.logError(e, "Failed to load parent menu definition '" + parentMenu + "' at resource '" + parentResource
+                            + "'", module);
                 }
             } else {
+                parentResource = menuLocation;
                 // try to find a menu definition in the same file
                 Element rootElement = menuElement.getOwnerDocument().getDocumentElement();
                 List<? extends Element> menuElements = UtilXml.childElementList(rootElement, "menu");
@@ -114,7 +158,7 @@ public class ModelMenu extends ModelWidg
                 //menuElements.addAll(UtilXml.childElementList(rootElement, "abstract-menu"));
                 for (Element menuElementEntry : menuElements) {
                     if (menuElementEntry.getAttribute("name").equals(parentMenu)) {
-                        parent = new ModelMenu(menuElementEntry);
+                        parent = new ModelMenu(menuElementEntry, parentResource);
                         break;
                     }
                 }
@@ -122,206 +166,178 @@ public class ModelMenu extends ModelWidg
                     Debug.logError("Failed to find parent menu definition '" + parentMenu + "' in same document.", module);
                 }
             }
-
             if (parent != null) {
-                this.type = parent.type;
-                this.target = parent.target;
-                this.id = parent.id;
-                this.title = parent.title;
-                this.tooltip = parent.tooltip;
-                this.defaultEntityName = parent.defaultEntityName;
-                this.defaultTitleStyle = parent.defaultTitleStyle;
-                this.defaultSelectedStyle = parent.defaultSelectedStyle;
-                this.defaultWidgetStyle = parent.defaultWidgetStyle;
-                this.defaultTooltipStyle = parent.defaultTooltipStyle;
-                this.defaultMenuItemName = parent.defaultMenuItemName;
-                this.menuItemList.addAll(parent.menuItemList);
-                this.menuItemMap.putAll(parent.menuItemMap);
-                this.defaultPermissionOperation = parent.defaultPermissionOperation;
-                this.defaultPermissionEntityAction = parent.defaultPermissionEntityAction;
-                this.defaultAssociatedContentId = parent.defaultAssociatedContentId;
-                this.defaultPermissionStatusId = parent.defaultPermissionStatusId;
-                this.defaultPrivilegeEnumId = parent.defaultPrivilegeEnumId;
-                this.defaultHideIfSelected = parent.defaultHideIfSelected;
-                this.orientation = parent.orientation;
-                this.menuWidth = parent.menuWidth;
-                this.defaultCellWidth = parent.defaultCellWidth;
-                this.defaultDisabledTitleStyle = parent.defaultDisabledTitleStyle;
-                this.defaultAlign = parent.defaultAlign;
-                this.defaultAlignStyle = parent.defaultAlignStyle;
-                this.fillStyle = parent.fillStyle;
-                this.extraIndex = parent.extraIndex;
-                this.selectedMenuItemContextFieldName = parent.selectedMenuItemContextFieldName;
-                this.menuContainerStyleExdr = parent.menuContainerStyleExdr;
+                type = parent.type;
+                target = parent.target;
+                id = parent.id;
+                title = parent.title;
+                tooltip = parent.tooltip;
+                defaultEntityName = parent.defaultEntityName;
+                defaultTitleStyle = parent.defaultTitleStyle;
+                defaultSelectedStyle = parent.defaultSelectedStyle;
+                defaultWidgetStyle = parent.defaultWidgetStyle;
+                defaultTooltipStyle = parent.defaultTooltipStyle;
+                defaultMenuItemName = parent.defaultMenuItemName;
+                menuItemList.addAll(parent.menuItemList);
+                menuItemMap.putAll(parent.menuItemMap);
+                defaultPermissionOperation = parent.defaultPermissionOperation;
+                defaultPermissionEntityAction = parent.defaultPermissionEntityAction;
+                defaultAssociatedContentId = parent.defaultAssociatedContentId;
+                defaultPermissionStatusId = parent.defaultPermissionStatusId;
+                defaultPrivilegeEnumId = parent.defaultPrivilegeEnumId;
+                defaultHideIfSelected = parent.defaultHideIfSelected;
+                orientation = parent.orientation;
+                menuWidth = parent.menuWidth;
+                defaultCellWidth = parent.defaultCellWidth;
+                defaultDisabledTitleStyle = parent.defaultDisabledTitleStyle;
+                defaultAlign = parent.defaultAlign;
+                defaultAlignStyle = parent.defaultAlignStyle;
+                fillStyle = parent.fillStyle;
+                extraIndex = parent.extraIndex;
+                selectedMenuItemContextFieldName = parent.selectedMenuItemContextFieldName;
+                menuContainerStyleExdr = parent.menuContainerStyleExdr;
                 if (parent.actions != null) {
-                    this.actions = new ArrayList<ModelWidgetAction>();
-                    this.actions.addAll(parent.actions);
+                    actions.addAll(parent.actions);
                 }
             }
         }
-
-        if (this.type == null || menuElement.hasAttribute("type"))
-            this.type = menuElement.getAttribute("type");
-        if (this.target == null || menuElement.hasAttribute("target"))
-            this.target = menuElement.getAttribute("target");
-        if (this.id == null || menuElement.hasAttribute("id"))
-            this.id = menuElement.getAttribute("id");
-        if (this.title == null || menuElement.hasAttribute("title"))
-            this.setTitle(menuElement.getAttribute("title"));
-        if (this.tooltip == null || menuElement.hasAttribute("tooltip"))
-            this.tooltip = menuElement.getAttribute("tooltip");
-        if (this.defaultEntityName == null || menuElement.hasAttribute("default-entity-name"))
-            this.defaultEntityName = menuElement.getAttribute("default-entity-name");
-        if (this.defaultTitleStyle == null || menuElement.hasAttribute("default-title-style"))
-            this.defaultTitleStyle = menuElement.getAttribute("default-title-style");
-        if (this.defaultSelectedStyle == null || menuElement.hasAttribute("default-selected-style"))
-            this.defaultSelectedStyle = menuElement.getAttribute("default-selected-style");
-        if (this.defaultWidgetStyle == null || menuElement.hasAttribute("default-widget-style"))
-            this.defaultWidgetStyle = menuElement.getAttribute("default-widget-style");
-        if (this.defaultTooltipStyle == null || menuElement.hasAttribute("default-tooltip-style"))
-            this.defaultTooltipStyle = menuElement.getAttribute("default-tooltip-style");
-        if (this.defaultMenuItemName == null || menuElement.hasAttribute("default-menu-item-name"))
-            this.defaultMenuItemName = menuElement.getAttribute("default-menu-item-name");
-        if (this.defaultPermissionOperation == null || menuElement.hasAttribute("default-permission-operation"))
-            this.defaultPermissionOperation = menuElement.getAttribute("default-permission-operation");
-        if (this.defaultPermissionEntityAction == null || menuElement.hasAttribute("default-permission-entity-action"))
-            this.defaultPermissionEntityAction = menuElement.getAttribute("default-permission-entity-action");
-        if (this.defaultPermissionStatusId == null || menuElement.hasAttribute("defaultPermissionStatusId"))
-            this.defaultPermissionStatusId = menuElement.getAttribute("default-permission-status-id");
-        if (this.defaultPrivilegeEnumId == null || menuElement.hasAttribute("defaultPrivilegeEnumId"))
-            this.defaultPrivilegeEnumId = menuElement.getAttribute("default-privilege-enum-id");
-        if (this.defaultAssociatedContentId == null || menuElement.hasAttribute("defaultAssociatedContentId"))
-            this.setDefaultAssociatedContentId(menuElement.getAttribute("default-associated-content-id"));
-        if (this.orientation == null || menuElement.hasAttribute("orientation"))
-            this.orientation = menuElement.getAttribute("orientation");
-        if (this.menuWidth == null || menuElement.hasAttribute("menu-width"))
-            this.menuWidth = menuElement.getAttribute("menu-width");
-        if (this.defaultCellWidth == null || menuElement.hasAttribute("default-cell-width"))
-            this.defaultCellWidth = menuElement.getAttribute("default-cell-width");
-        if (menuElement.hasAttribute("default-hide-if-selected")) {
-            String val = menuElement.getAttribute("default-hide-if-selected");
-            if (val != null && val.equalsIgnoreCase("true"))
-                defaultHideIfSelected = Boolean.TRUE;
-            else
-                defaultHideIfSelected = Boolean.FALSE;
-        }
-        if (this.defaultDisabledTitleStyle == null || menuElement.hasAttribute("default-disabled-title-style"))
-            this.defaultDisabledTitleStyle = menuElement.getAttribute("default-disabled-title-style");
-        if (this.selectedMenuItemContextFieldName == null || menuElement.hasAttribute("selected-menuitem-context-field-name"))
-            this.selectedMenuItemContextFieldName = FlexibleMapAccessor.getInstance(menuElement.getAttribute("selected-menuitem-context-field-name"));
-        if (this.menuContainerStyleExdr == null || menuElement.hasAttribute("menu-container-style"))
-            this.setMenuContainerStyle(menuElement.getAttribute("menu-container-style"));
-        if (this.defaultAlign == null || menuElement.hasAttribute("default-align"))
-            this.defaultAlign = menuElement.getAttribute("default-align");
-        if (this.defaultAlignStyle == null || menuElement.hasAttribute("default-align-style"))
-            this.defaultAlignStyle = menuElement.getAttribute("default-align-style");
-        if (this.fillStyle == null || menuElement.hasAttribute("fill-style"))
-            this.fillStyle = menuElement.getAttribute("fill-style");
- if (this.extraIndex == null || menuElement.hasAttribute("extra-index"))
-            this.setExtraIndex(menuElement.getAttribute("extra-index"));
-
+        if (menuElement.hasAttribute("type"))
+            type = menuElement.getAttribute("type");
+        if (menuElement.hasAttribute("target"))
+            target = menuElement.getAttribute("target");
+        if (menuElement.hasAttribute("id"))
+            id = menuElement.getAttribute("id");
+        if (menuElement.hasAttribute("title"))
+            title = FlexibleStringExpander.getInstance(menuElement.getAttribute("title"));
+        if (menuElement.hasAttribute("tooltip"))
+            tooltip = menuElement.getAttribute("tooltip");
+        if (menuElement.hasAttribute("default-entity-name"))
+            defaultEntityName = menuElement.getAttribute("default-entity-name");
+        if (menuElement.hasAttribute("default-title-style"))
+            defaultTitleStyle = menuElement.getAttribute("default-title-style");
+        if (menuElement.hasAttribute("default-selected-style"))
+            defaultSelectedStyle = menuElement.getAttribute("default-selected-style");
+        if (menuElement.hasAttribute("default-widget-style"))
+            defaultWidgetStyle = menuElement.getAttribute("default-widget-style");
+        if (menuElement.hasAttribute("default-tooltip-style"))
+            defaultTooltipStyle = menuElement.getAttribute("default-tooltip-style");
+        if (menuElement.hasAttribute("default-menu-item-name"))
+            defaultMenuItemName = menuElement.getAttribute("default-menu-item-name");
+        if (menuElement.hasAttribute("default-permission-operation"))
+            defaultPermissionOperation = menuElement.getAttribute("default-permission-operation");
+        if (menuElement.hasAttribute("default-permission-entity-action"))
+            defaultPermissionEntityAction = menuElement.getAttribute("default-permission-entity-action");
+        if (menuElement.hasAttribute("defaultPermissionStatusId"))
+            defaultPermissionStatusId = menuElement.getAttribute("default-permission-status-id");
+        if (menuElement.hasAttribute("defaultPrivilegeEnumId"))
+            defaultPrivilegeEnumId = menuElement.getAttribute("default-privilege-enum-id");
+        if (menuElement.hasAttribute("defaultAssociatedContentId"))
+            defaultAssociatedContentId = FlexibleStringExpander.getInstance(menuElement
+                    .getAttribute("default-associated-content-id"));
+        if (menuElement.hasAttribute("orientation"))
+            orientation = menuElement.getAttribute("orientation");
+        if (menuElement.hasAttribute("menu-width"))
+            menuWidth = menuElement.getAttribute("menu-width");
+        if (menuElement.hasAttribute("default-cell-width"))
+            defaultCellWidth = menuElement.getAttribute("default-cell-width");
+        if (menuElement.hasAttribute("default-hide-if-selected"))
+            defaultHideIfSelected = "true".equals(menuElement.getAttribute("default-hide-if-selected"));
+        if (menuElement.hasAttribute("default-disabled-title-style"))
+            defaultDisabledTitleStyle = menuElement.getAttribute("default-disabled-title-style");
+        if (menuElement.hasAttribute("selected-menuitem-context-field-name"))
+            selectedMenuItemContextFieldName = FlexibleMapAccessor.getInstance(menuElement
+                    .getAttribute("selected-menuitem-context-field-name"));
+        if (menuElement.hasAttribute("menu-container-style"))
+            menuContainerStyleExdr = FlexibleStringExpander.getInstance(menuElement.getAttribute("menu-container-style"));
+        if (menuElement.hasAttribute("default-align"))
+            defaultAlign = menuElement.getAttribute("default-align");
+        if (menuElement.hasAttribute("default-align-style"))
+            defaultAlignStyle = menuElement.getAttribute("default-align-style");
+        if (menuElement.hasAttribute("fill-style"))
+            fillStyle = menuElement.getAttribute("fill-style");
+        if (menuElement.hasAttribute("extra-index"))
+            extraIndex = FlexibleStringExpander.getInstance(menuElement.getAttribute("extra-index"));
         // read all actions under the "actions" element
         Element actionsElement = UtilXml.firstChildElement(menuElement, "actions");
         if (actionsElement != null) {
-            if (this.actions == null) {
-                this.actions = ModelMenuAction.readSubActions(this, actionsElement);
-            } else {
-                this.actions.addAll(ModelMenuAction.readSubActions(this, actionsElement));
-                ArrayList<ModelWidgetAction> actionsList = (ArrayList<ModelWidgetAction>)this.actions;
-                actionsList.trimToSize();
-            }
+            actions.addAll(ModelMenuAction.readSubActions(this, actionsElement));
         }
-
-        // read in add item defs, add/override one by one using the menuItemList
+        actions.trimToSize();
+        this.actions = Collections.unmodifiableList(actions);
+        this.defaultAlign = defaultAlign;
+        this.defaultAlignStyle = defaultAlignStyle;
+        this.defaultAssociatedContentId = defaultAssociatedContentId;
+        this.defaultCellWidth = defaultCellWidth;
+        this.defaultDisabledTitleStyle = defaultDisabledTitleStyle;
+        this.defaultEntityName = defaultEntityName;
+        this.defaultHideIfSelected = defaultHideIfSelected;
+        this.defaultMenuItemName = defaultMenuItemName;
+        this.defaultPermissionEntityAction = defaultPermissionEntityAction;
+        this.defaultPermissionOperation = defaultPermissionOperation;
+        this.defaultPermissionStatusId = defaultPermissionStatusId;
+        this.defaultPrivilegeEnumId = defaultPrivilegeEnumId;
+        this.defaultSelectedStyle = defaultSelectedStyle;
+        this.defaultTitleStyle = defaultTitleStyle;
+        this.defaultTooltipStyle = defaultTooltipStyle;
+        this.defaultWidgetStyle = defaultWidgetStyle;
+        this.extraIndex = extraIndex;
+        this.fillStyle = fillStyle;
+        this.id = id;
+        this.menuContainerStyleExdr = menuContainerStyleExdr;
         List<? extends Element> itemElements = UtilXml.childElementList(menuElement, "menu-item");
         for (Element itemElement : itemElements) {
             ModelMenuItem modelMenuItem = new ModelMenuItem(itemElement, this);
-            modelMenuItem = this.addUpdateMenuItem(modelMenuItem);
+            addUpdateMenuItem(modelMenuItem, menuItemList, menuItemMap);
         }
+        menuItemList.trimToSize();
+        this.menuItemList = Collections.unmodifiableList(menuItemList);
+        this.menuItemMap = Collections.unmodifiableMap(menuItemMap);
+        this.menuLocation = menuLocation;
+        this.menuWidth = menuWidth;
+        this.orientation = orientation;
+        this.selectedMenuItemContextFieldName = selectedMenuItemContextFieldName;
+        this.target = target;
+        this.title = title;
+        this.tooltip = tooltip;
+        this.type = type;
+    }
+
+    @Override
+    public void accept(ModelWidgetVisitor visitor) throws Exception {
+        visitor.visit(this);
     }
 
     /**
      * add/override modelMenuItem using the menuItemList and menuItemMap
      *
-     * @return The same ModelMenuItem, or if merged with an existing item, the existing item.
      */
-    public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) {
-        // not a conditional item, see if a named item exists in Map
-        ModelMenuItem existingMenuItem = this.menuItemMap.get(modelMenuItem.getName());
+    private void addUpdateMenuItem(ModelMenuItem modelMenuItem, List<ModelMenuItem> menuItemList,
+            Map<String, ModelMenuItem> menuItemMap) {
+        ModelMenuItem existingMenuItem = menuItemMap.get(modelMenuItem.getName());
         if (existingMenuItem != null) {
             // does exist, update the item by doing a merge/override
-            existingMenuItem.mergeOverrideModelMenuItem(modelMenuItem);
-            return existingMenuItem;
-        } else {
-            // does not exist, add to List and Map
-            this.menuItemList.add(modelMenuItem);
-            this.menuItemMap.put(modelMenuItem.getName(), modelMenuItem);
-            return modelMenuItem;
-        }
-    }
-
-    public ModelMenuItem getModelMenuItemByName(String name) {
-        return this.menuItemMap.get(name);
-    }
-
-    /**
-     * 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 {
-        ModelWidgetAction.runSubActions(this.actions, context);
-        if ("simple".equals(this.type)) {
-            this.renderSimpleMenuString(writer, context, menuStringRenderer);
+            ModelMenuItem mergedMenuItem = existingMenuItem.mergeOverrideModelMenuItem(modelMenuItem);
+            int existingItemIndex = menuItemList.indexOf(existingMenuItem);
+            menuItemList.set(existingItemIndex, mergedMenuItem);
+            menuItemMap.put(modelMenuItem.getName(), mergedMenuItem);
         } else {
-            throw new IllegalArgumentException("The type " + this.getType() + " is not supported for menu with name " + this.getName());
+            // does not exist, add to Map
+            menuItemList.add(modelMenuItem);
+            menuItemMap.put(modelMenuItem.getName(), modelMenuItem);
         }
     }
 
-    public void runActions(Map<String, Object> context) {
-        ModelWidgetAction.runSubActions(this.actions, context);
+    public List<ModelWidgetAction> getActions() {
+        return actions;
     }
 
-    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 {
-        // render menu open
-        menuStringRenderer.renderMenuOpen(writer, context, this);
-
-        // render formatting wrapper open
-        menuStringRenderer.renderFormatSimpleWrapperOpen(writer, context, this);
-
-        // render each menuItem row, except hidden & ignored rows
-        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);
+    @Override
+    public String getBoundaryCommentName() {
+        return menuLocation + "#" + getName();
     }
 
-    public String getDefaultEntityName() {
-        return this.defaultEntityName;
+    public String getCurrentMenuName(Map<String, Object> context) {
+        return getName();
     }
 
     public String getDefaultAlign() {
@@ -332,278 +348,205 @@ public class ModelMenu extends ModelWidg
         return this.defaultAlignStyle;
     }
 
-    public String getDefaultTitleStyle() {
-        return this.defaultTitleStyle;
-    }
-
-    public String getDefaultDisabledTitleStyle() {
-        return this.defaultDisabledTitleStyle;
-    }
-
-    public String getDefaultSelectedStyle() {
-        return this.defaultSelectedStyle;
-    }
-
-    public String getDefaultWidgetStyle() {
-        return this.defaultWidgetStyle;
-    }
-
-    public String getDefaultTooltipStyle() {
-        return this.defaultTooltipStyle;
+    public FlexibleStringExpander getDefaultAssociatedContentId() {
+        return defaultAssociatedContentId;
     }
 
-    public String getDefaultMenuItemName() {
-        return this.defaultMenuItemName;
-    }
-
-    public String getFillStyle() {
-        return this.fillStyle;
-    }
-
-    public String getSelectedMenuItemContextFieldName(Map<String, Object> context) {
-        String menuItemName = this.selectedMenuItemContextFieldName.get(context);
-        if (UtilValidate.isEmpty(menuItemName)) {
-            return this.defaultMenuItemName;
-        }
-        return menuItemName;
-    }
-
-    public String getCurrentMenuName(Map<String, Object> context) {
-        return getName();
-    }
-
-    public String getId() {
-        return this.id;
-    }
-
-    public String getTitle(Map<String, Object> context) {
-        return title.expandString(context);
+    public String getDefaultAssociatedContentId(Map<String, Object> context) {
+        return defaultAssociatedContentId.expandString(context);
     }
 
-    public String getTooltip() {
-        return this.tooltip;
+    public String getDefaultCellWidth() {
+        return this.defaultCellWidth;
     }
 
-    public String getType() {
-        return this.type;
+    public String getDefaultDisabledTitleStyle() {
+        return this.defaultDisabledTitleStyle;
     }
 
-    @Override
-    public String getBoundaryCommentName() {
-        return menuLocation + "#" + getName();
+    public String getDefaultEntityName() {
+        return this.defaultEntityName;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultEntityName(String string) {
-        this.defaultEntityName = string;
+    public Boolean getDefaultHideIfSelected() {
+        return this.defaultHideIfSelected;
     }
 
-
-    /**
-     * @param string
-     */
-    public void setDefaultTitleStyle(String string) {
-        this.defaultTitleStyle = string;
+    public String getDefaultMenuItemName() {
+        return this.defaultMenuItemName;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultSelectedStyle(String string) {
-        this.defaultSelectedStyle = string;
+    public String getDefaultPermissionEntityAction() {
+        return this.defaultPermissionEntityAction;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultWidgetStyle(String string) {
-        this.defaultWidgetStyle = string;
+    public String getDefaultPermissionOperation() {
+        return this.defaultPermissionOperation;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultTooltipStyle(String string) {
-        this.defaultTooltipStyle = string;
+    public String getDefaultPermissionStatusId() {
+        return this.defaultPermissionStatusId;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultMenuItemName(String string) {
-        this.defaultMenuItemName = string;
+    public String getDefaultPrivilegeEnumId() {
+        return this.defaultPrivilegeEnumId;
     }
 
-    /**
-     * @param menuLocation the menu location to set
-     */
-    public void setMenuLocation(String menuLocation) {
-        this.menuLocation = menuLocation;
+    public String getDefaultSelectedStyle() {
+        return this.defaultSelectedStyle;
     }
 
-    /**
-     * @param string
-     */
-    public void setTarget(String string) {
-        this.target = string;
+    public String getDefaultTitleStyle() {
+        return this.defaultTitleStyle;
     }
 
-    /**
-     * @param string
-     */
-    public void setId(String string) {
-        this.id = string;
+    public String getDefaultTooltipStyle() {
+        return this.defaultTooltipStyle;
     }
 
-    /**
-     * @param string
-     */
-    public void setTitle(String string) {
-        this.title = FlexibleStringExpander.getInstance(string);
+    public String getDefaultWidgetStyle() {
+        return this.defaultWidgetStyle;
     }
 
-    /**
-     * @param string
-     */
-    public void setTooltip(String string) {
-        this.tooltip = string;
+    public FlexibleStringExpander getExtraIndex() {
+        return extraIndex;
     }
 
-    /**
-     * @param string
-     */
-    public void setType(String string) {
-        this.type = string;
+    public String getExtraIndex(Map<String, Object> context) {
+        try {
+            return extraIndex.expandString(context);
+        } catch (Exception ex) {
+            return "";
+        }
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultAssociatedContentId(String string) {
-        this.defaultAssociatedContentId = FlexibleStringExpander.getInstance(string);
+    public String getFillStyle() {
+        return this.fillStyle;
     }
 
-    /**
-     * @param string
-     */
-    public void setMenuContainerStyle(String string) {
-        this.menuContainerStyleExdr = FlexibleStringExpander.getInstance(string);
+    public String getId() {
+        return this.id;
     }
 
-    public String getDefaultAssociatedContentId(Map<String, Object> context) {
-        return defaultAssociatedContentId.expandString(context);
-    }
     public String getMenuContainerStyle(Map<String, Object> context) {
         return menuContainerStyleExdr.expandString(context);
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultPermissionOperation(String string) {
-        this.defaultPermissionOperation = string;
+    public FlexibleStringExpander getMenuContainerStyleExdr() {
+        return menuContainerStyleExdr;
     }
 
-    public String getDefaultPermissionStatusId() {
-        return this.defaultPermissionStatusId;
+    public List<ModelMenuItem> getMenuItemList() {
+        return menuItemList;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultPermissionStatusId(String string) {
-        this.defaultPermissionStatusId = string;
+    public Map<String, ModelMenuItem> getMenuItemMap() {
+        return menuItemMap;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultPrivilegeEnumId(String string) {
-        this.defaultPrivilegeEnumId = string;
+    public String getMenuLocation() {
+        return menuLocation;
     }
 
-    public String getDefaultPrivilegeEnumId() {
-        return this.defaultPrivilegeEnumId;
+    public String getMenuWidth() {
+        return this.menuWidth;
     }
 
-    /**
-     * @param string
-     */
-    public void setOrientation(String string) {
-        this.orientation = string;
+    public ModelMenuItem getModelMenuItemByName(String name) {
+        return this.menuItemMap.get(name);
     }
 
     public String getOrientation() {
         return this.orientation;
     }
 
-    /**
-     * @param string
-     */
-    public void setMenuWidth(String string) {
-        this.menuWidth = string;
+    public FlexibleMapAccessor<String> getSelectedMenuItemContextFieldName() {
+        return selectedMenuItemContextFieldName;
     }
 
-    public String getMenuWidth() {
-        return this.menuWidth;
+    public String getSelectedMenuItemContextFieldName(Map<String, Object> context) {
+        String menuItemName = this.selectedMenuItemContextFieldName.get(context);
+        if (UtilValidate.isEmpty(menuItemName)) {
+            return this.defaultMenuItemName;
+        }
+        return menuItemName;
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultCellWidth(String string) {
-        this.defaultCellWidth = string;
+    public String getTarget() {
+        return target;
     }
 
-    public String getDefaultCellWidth() {
-        return this.defaultCellWidth;
+    public FlexibleStringExpander getTitle() {
+        return title;
     }
 
-    public String getDefaultPermissionOperation() {
-        return this.defaultPermissionOperation;
+    public String getTitle(Map<String, Object> context) {
+        return title.expandString(context);
     }
 
-    /**
-     * @param string
-     */
-    public void setDefaultPermissionEntityAction(String string) {
-        this.defaultPermissionEntityAction = string;
+    public String getTooltip() {
+        return this.tooltip;
     }
 
-    public String getDefaultPermissionEntityAction() {
-        return this.defaultPermissionEntityAction;
+    public String getType() {
+        return this.type;
+    }
+
+    public int renderedMenuItemCount(Map<String, Object> context) {
+        int count = 0;
+        for (ModelMenuItem item : this.menuItemList) {
+            if (item.shouldBeRendered(context))
+                count++;
+        }
+        return count;
     }
 
     /**
-     * @param val
+     * 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 setDefaultHideIfSelected(Boolean val) {
-        this.defaultHideIfSelected = val;
+    public void renderMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer)
+            throws IOException {
+        ModelWidgetAction.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());
+        }
     }
 
-    public Boolean getDefaultHideIfSelected() {
-        return this.defaultHideIfSelected;
-    }
+    public void renderSimpleMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer)
+            throws IOException {
+        // render menu open
+        menuStringRenderer.renderMenuOpen(writer, context, this);
 
-    public List<ModelMenuItem> getMenuItemList() {
-        return menuItemList;
-    }
- public String getExtraIndex(Map<String, Object> context) {
-        try {
-            return extraIndex.expandString(context);
-        } catch (Exception ex) {
-            return "";
+        // render formatting wrapper open
+        menuStringRenderer.renderFormatSimpleWrapperOpen(writer, context, this);
+
+        // render each menuItem row, except hidden & ignored rows
+        for (ModelMenuItem item : this.menuItemList) {
+            item.renderMenuItemString(writer, context, menuStringRenderer);
         }
-    }
+        // render formatting wrapper close
+        menuStringRenderer.renderFormatSimpleWrapperClose(writer, context, this);
 
-    public void setExtraIndex(String extraIndex) {
-        this.extraIndex = FlexibleStringExpander.getInstance(extraIndex);
+        // render menu close
+        menuStringRenderer.renderMenuClose(writer, context, this);
     }
 
-    @Override
-    public void accept(ModelWidgetVisitor visitor) throws Exception {
-        visitor.visit(this);
+    public void runActions(Map<String, Object> context) {
+        ModelWidgetAction.runSubActions(this.actions, context);
     }
 }

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Mon Jan  5 08:50:30 2015
@@ -43,7 +43,7 @@ import org.ofbiz.widget.ModelWidgetActio
 import org.w3c.dom.Element;
 
 /**
- * Widget Library - Screen model class
+ * Abstract menu action.
  */
 public abstract class ModelMenuAction {
 
@@ -56,22 +56,27 @@ public abstract class ModelMenuAction {
             if ("set".equals(actionElement.getNodeName())) {
                 actions.add(new SetField(modelMenu, actionElement));
             } else {
-                actions.add(ModelWidgetAction.toModelWidgetAction(modelMenu, actionElement));
+                actions.add(ModelWidgetAction.newInstance(modelMenu, actionElement));
             }
         }
         return Collections.unmodifiableList(actions);
     }
 
+    /**
+     * Models the &lt;set&gt; element.
+     *
+     * @see <code>widget-common.xsd</code>
+     */
     @SuppressWarnings("serial")
     public static class SetField extends ModelWidgetAction {
-        protected FlexibleMapAccessor<Object> field;
-        protected FlexibleMapAccessor<Object> fromField;
-        protected FlexibleStringExpander valueExdr;
-        protected FlexibleStringExpander defaultExdr;
-        protected FlexibleStringExpander globalExdr;
-        protected String type;
-        protected String toScope;
-        protected String fromScope;
+        private final FlexibleMapAccessor<Object> field;
+        private final FlexibleMapAccessor<Object> fromField;
+        private final FlexibleStringExpander valueExdr;
+        private final FlexibleStringExpander defaultExdr;
+        private final FlexibleStringExpander globalExdr;
+        private final String type;
+        private final String toScope;
+        private final String fromScope;
 
         public SetField(ModelMenu modelMenu, Element setElement) {
             super (modelMenu, setElement);

Modified: ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java?rev=1649482&r1=1649481&r2=1649482&view=diff
==============================================================================
--- ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java (original)
+++ ofbiz/branches/OFBIZ-5312-ofbiz-ecommerce-seo-2013-10-23/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java Mon Jan  5 08:50:30 2015
@@ -18,545 +18,48 @@
  *******************************************************************************/
 package org.ofbiz.widget.menu;
 
-import java.lang.reflect.Method;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternMatcher;
-import org.apache.oro.text.regex.Perl5Matcher;
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.ObjectType;
-import org.ofbiz.base.util.PatternFactory;
-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.minilang.operation.BaseCompare;
-import org.ofbiz.security.Security;
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ModelService;
-import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.widget.ModelWidgetCondition;
 import org.w3c.dom.Element;
 
 /**
- * Widget Library - Screen model condition class
+ * Models the &lt;condition&gt; element.
+ *
+ * @see <code>widget-menu.xsd</code>
  */
-public class ModelMenuCondition {
+@SuppressWarnings("serial")
+public class ModelMenuCondition extends ModelWidgetCondition {
+
+    /*
+     * ----------------------------------------------------------------------- *
+     *                     DEVELOPERS PLEASE READ
+     * ----------------------------------------------------------------------- *
+     *
+     * This model is intended to be a read-only data structure that represents
+     * an XML element. Outside of object construction, the class should not
+     * have any behaviors.
+     *
+     * Instances of this class will be shared by multiple threads - therefore
+     * it is immutable. DO NOT CHANGE THE OBJECT'S STATE AT RUN TIME!
+     *
+     */
+
     public static final String module = ModelMenuCondition.class.getName();
 
-    protected ModelMenuItem modelMenuItem;
-    protected MenuCondition rootCondition;
-    protected FlexibleStringExpander passStyleExdr;
-    protected FlexibleStringExpander failStyleExdr;
+    private final FlexibleStringExpander passStyleExdr;
+    private final FlexibleStringExpander failStyleExdr;
 
     public ModelMenuCondition(ModelMenuItem modelMenuItem, Element conditionElement) {
-        this.modelMenuItem = modelMenuItem;
+        super(ModelWidgetCondition.DEFAULT_CONDITION_FACTORY, modelMenuItem, conditionElement);
         this.passStyleExdr = FlexibleStringExpander.getInstance(conditionElement.getAttribute("pass-style"));
         this.failStyleExdr = FlexibleStringExpander.getInstance(conditionElement.getAttribute("disabled-style"));
-        Element firstChildElement = UtilXml.firstChildElement(conditionElement);
-        this.rootCondition = readCondition(modelMenuItem, firstChildElement);
-    }
-
-    public boolean eval(Map<String, Object> context) {
-        if (rootCondition == null) {
-            return true;
-        }
-        boolean cond = rootCondition.eval(context);
-        if (cond) {
-            String passStyle = passStyleExdr.expandString(context);
-            if (UtilValidate.isNotEmpty(passStyle)) {
-                modelMenuItem.setWidgetStyle(passStyle);
-            }
-            modelMenuItem.setDisabled(false);
-        } else {
-            String failStyle = failStyleExdr.expandString(context);
-            if (UtilValidate.isNotEmpty(failStyle)) {
-                modelMenuItem.setDisabledTitleStyle(failStyle);
-                modelMenuItem.setDisabled(true);
-                cond = true;
-            }
-        }
-        return cond;
-    }
-
-    public static abstract class MenuCondition {
-        protected ModelMenuItem modelMenuItem;
-
-        public MenuCondition(ModelMenuItem modelMenuItem, Element conditionElement) {
-            this.modelMenuItem = modelMenuItem;
-        }
-
-        public abstract boolean eval(Map<String, Object> context);
-    }
-
-    public static List<MenuCondition> readSubConditions(ModelMenuItem modelMenuItem, Element conditionElement) {
-        List<MenuCondition> condList = new LinkedList<MenuCondition>();
-        List<? extends Element> subElementList = UtilXml.childElementList(conditionElement);
-        for (Element subElement: subElementList) {
-            condList.add(readCondition(modelMenuItem, subElement));
-        }
-        return condList;
-    }
-
-    public static MenuCondition readCondition(ModelMenuItem modelMenuItem, Element conditionElement) {
-        if (conditionElement == null) {
-            return null;
-        }
-        if ("and".equals(conditionElement.getNodeName())) {
-            return new And(modelMenuItem, conditionElement);
-        } else if ("xor".equals(conditionElement.getNodeName())) {
-            return new Xor(modelMenuItem, conditionElement);
-        } else if ("or".equals(conditionElement.getNodeName())) {
-            return new Or(modelMenuItem, conditionElement);
-        } else if ("not".equals(conditionElement.getNodeName())) {
-            return new Not(modelMenuItem, conditionElement);
-        } else if ("if-service-permission".equals(conditionElement.getNodeName())) {
-            return new IfServicePermission(modelMenuItem, conditionElement);
-        } else if ("if-has-permission".equals(conditionElement.getNodeName())) {
-            return new IfHasPermission(modelMenuItem, conditionElement);
-        } else if ("if-validate-method".equals(conditionElement.getNodeName())) {
-            return new IfValidateMethod(modelMenuItem, conditionElement);
-        } else if ("if-compare".equals(conditionElement.getNodeName())) {
-            return new IfCompare(modelMenuItem, conditionElement);
-        } else if ("if-compare-field".equals(conditionElement.getNodeName())) {
-            return new IfCompareField(modelMenuItem, conditionElement);
-        } else if ("if-regexp".equals(conditionElement.getNodeName())) {
-            return new IfRegexp(modelMenuItem, conditionElement);
-        } else if ("if-empty".equals(conditionElement.getNodeName())) {
-            return new IfEmpty(modelMenuItem, conditionElement);
-        } else if ("if-entity-permission".equals(conditionElement.getNodeName())) {
-            return new IfEntityPermission(modelMenuItem, conditionElement);
-        } else {
-            throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName());
-        }
-    }
-
-    public static class And extends MenuCondition {
-        protected List<MenuCondition> subConditions;
-
-        public And(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.subConditions = readSubConditions(modelMenuItem, condElement);
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            // return false for the first one in the list that is false, basic and algo
-            for (MenuCondition subCondition: this.subConditions) {
-                if (!subCondition.eval(context)) {
-                    return false;
-                }
-            }
-            return true;
-        }
-    }
-
-    public static class Xor extends MenuCondition {
-        protected List<MenuCondition> subConditions;
-
-        public Xor(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.subConditions = readSubConditions(modelMenuItem, condElement);
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            // if more than one is true stop immediately and return false; if all are false return false; if only one is true return true
-            boolean foundOneTrue = false;
-            for (MenuCondition subCondition: this.subConditions) {
-                if (subCondition.eval(context)) {
-                    if (foundOneTrue) {
-                        // now found two true, so return false
-                        return false;
-                    } else {
-                        foundOneTrue = true;
-                    }
-                }
-            }
-            return foundOneTrue;
-        }
-    }
-
-    public static class Or extends MenuCondition {
-        protected List<MenuCondition> subConditions;
-
-        public Or(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.subConditions = readSubConditions(modelMenuItem, condElement);
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            // return true for the first one in the list that is true, basic or algo
-            for (MenuCondition subCondition: this.subConditions) {
-                if (subCondition.eval(context)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    public static class Not extends MenuCondition {
-        protected MenuCondition subCondition;
-
-        public Not(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            Element firstChildElement = UtilXml.firstChildElement(condElement);
-            this.subCondition = readCondition(modelMenuItem, firstChildElement);
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            return !this.subCondition.eval(context);
-        }
-    }
-
-    public static class IfServicePermission extends MenuCondition {
-        protected FlexibleStringExpander serviceExdr;
-        protected FlexibleStringExpander actionExdr;
-        protected FlexibleStringExpander resExdr;
-
-        public IfServicePermission(ModelMenuItem modelMenuItem, Element condElement) {
-            super(modelMenuItem, condElement);
-            this.serviceExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("service-name"));
-            this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("main-action"));
-            this.resExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("resource-description"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            // if no user is logged in, treat as if the user does not have permission
-            GenericValue userLogin = (GenericValue) context.get("userLogin");
-            if (userLogin != null) {
-                String serviceName = serviceExdr.expandString(context);
-                String mainAction = actionExdr.expandString(context);
-                String resource = resExdr.expandString(context);
-                if (resource == null) {
-                    resource = serviceName;
-                }
-
-                if (serviceName == null) {
-                    Debug.logWarning("No permission service-name specified!", module);
-                    return false;
-                }
-
-                // get the service objects
-                LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
-                DispatchContext dctx = dispatcher.getDispatchContext();
-
-                // get the service
-                ModelService permService;
-                try {
-                    permService = dctx.getModelService(serviceName);
-                } catch (GenericServiceException e) {
-                    Debug.logError(e, module);
-                    return false;
-                }
-
-                if (permService != null) {
-                    // build the context
-                    Map<String, Object> svcCtx = permService.makeValid(context, ModelService.IN_PARAM);
-                    svcCtx.put("resourceDescription", resource);
-                    if (UtilValidate.isNotEmpty(mainAction)) {
-                        svcCtx.put("mainAction", mainAction);
-                    }
-
-                    // invoke the service
-                    Map<String, Object> resp;
-                    try {
-                        resp = dispatcher.runSync(permService.name,  svcCtx, 300, true);
-                    } catch (GenericServiceException e) {
-                        Debug.logError(e, module);
-                        return false;
-                    }
-                    if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) {
-                        Debug.logError(ServiceUtil.getErrorMessage(resp), module);
-                        return false;
-                    }
-                    Boolean hasPermission = (Boolean) resp.get("hasPermission");
-                    if (hasPermission != null) {
-                        return hasPermission.booleanValue();
-                    }
-                }
-            }
-            return false;
-        }
-    }
-
-    public static class IfHasPermission extends MenuCondition {
-        protected FlexibleStringExpander permissionExdr;
-        protected FlexibleStringExpander actionExdr;
-
-        public IfHasPermission(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.permissionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("permission"));
-            this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("action"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            // if no user is logged in, treat as if the user does not have permission
-            GenericValue userLogin = (GenericValue) context.get("userLogin");
-            if (userLogin != null) {
-                String permission = permissionExdr.expandString(context);
-                String action = actionExdr.expandString(context);
-                Security security = (Security) context.get("security");
-                if (UtilValidate.isNotEmpty(action)) {
-                    // run hasEntityPermission
-                    if (security.hasEntityPermission(permission, action, userLogin)) {
-                        return true;
-                    }
-                } else {
-                    // run hasPermission
-                    if (security.hasPermission(permission, userLogin)) {
-                        return true;
-                    }
-                }
-            }
-            return false;
-        }
-    }
-
-    public static class IfValidateMethod extends MenuCondition {
-        protected FlexibleMapAccessor<Object> fieldAcsr;
-        protected FlexibleStringExpander methodExdr;
-        protected FlexibleStringExpander classExdr;
-
-        public IfValidateMethod(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
-            if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
-            this.methodExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("method"));
-            this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            String methodName = this.methodExdr.expandString(context);
-            String className = this.classExdr.expandString(context);
-
-            Object fieldVal = this.fieldAcsr.get(context);
-            String fieldString = null;
-            if (fieldVal != null) {
-                try {
-                    fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, "String", null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
-                } catch (GeneralException e) {
-                    Debug.logError(e, "Could not convert object to String, using empty String", module);
-                }
-            }
-
-            // always use an empty string by default
-            if (fieldString == null) fieldString = "";
-
-            Class<?>[] paramTypes = new Class[] {String.class};
-            Object[] params = new Object[] {fieldString};
-
-            Class<?> valClass;
-            try {
-                valClass = ObjectType.loadClass(className);
-            } catch (ClassNotFoundException cnfe) {
-                Debug.logError("Could not find validation class: " + className, module);
-                return false;
-            }
-
-            Method valMethod;
-            try {
-                valMethod = valClass.getMethod(methodName, paramTypes);
-            } catch (NoSuchMethodException cnfe) {
-                Debug.logError("Could not find validation method: " + methodName + " of class " + className, module);
-                return false;
-            }
-
-            Boolean resultBool = Boolean.FALSE;
-            try {
-                resultBool = (Boolean) valMethod.invoke(null, params);
-            } catch (Exception e) {
-                Debug.logError(e, "Error in IfValidationMethod " + methodName + " of class " + className + ", defaulting to false ", module);
-            }
-
-            return resultBool.booleanValue();
-        }
     }
 
-    public static class IfCompare extends MenuCondition {
-        protected FlexibleMapAccessor<Object> fieldAcsr;
-        protected FlexibleStringExpander valueExdr;
-
-        protected String operator;
-        protected String type;
-        protected FlexibleStringExpander formatExdr;
-
-        public IfCompare(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
-            if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
-            this.valueExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("value"));
-
-            this.operator = condElement.getAttribute("operator");
-            this.type = condElement.getAttribute("type");
-
-            this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            String value = this.valueExdr.expandString(context);
-            String format = this.formatExdr.expandString(context);
-
-            Object fieldVal = this.fieldAcsr.get(context);
-
-            // always use an empty string by default
-            if (fieldVal == null) {
-                fieldVal = "";
-            }
-
-            List<Object> messages = new LinkedList<Object>();
-            Boolean resultBool = BaseCompare.doRealCompare(fieldVal, value, operator, type, format, messages, null, null, true);
-            if (messages.size() > 0) {
-                messages.add(0, "Error with comparison in if-compare between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and value [" + value + "] with operator [" + operator + "] and type [" + type + "]: ");
-
-                StringBuilder fullString = new StringBuilder();
-                for (Object message: messages) {
-                    fullString.append((String) message);
-                }
-                Debug.logWarning(fullString.toString(), module);
-
-                throw new IllegalArgumentException(fullString.toString());
-            }
-
-            return resultBool.booleanValue();
-        }
+    public FlexibleStringExpander getFailStyleExdr() {
+        return failStyleExdr;
     }
 
-    public static class IfCompareField extends MenuCondition {
-        protected FlexibleMapAccessor<Object> fieldAcsr;
-        protected FlexibleMapAccessor<Object> toFieldAcsr;
-
-        protected String operator;
-        protected String type;
-        protected FlexibleStringExpander formatExdr;
-
-        public IfCompareField(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
-            if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
-            this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field"));
-            if (this.toFieldAcsr.isEmpty()) this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field-name"));
-
-            this.operator = condElement.getAttribute("operator");
-            this.type = condElement.getAttribute("type");
-
-            this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            String format = this.formatExdr.expandString(context);
-
-            Object fieldVal = this.fieldAcsr.get(context);
-            Object toFieldVal = this.toFieldAcsr.get(context);
-
-            // always use an empty string by default
-            if (fieldVal == null) {
-                fieldVal = "";
-            }
-
-            List<Object> messages = new LinkedList<Object>();
-            Boolean resultBool = BaseCompare.doRealCompare(fieldVal, toFieldVal, operator, type, format, messages, null, null, false);
-            if (messages.size() > 0) {
-                messages.add(0, "Error with comparison in if-compare-field between field [" + fieldAcsr.toString() + "] with value [" + fieldVal + "] and to-field [" + toFieldVal.toString() + "] with value [" + toFieldVal + "] with operator [" + operator + "] and type [" + type + "]: ");
-
-                StringBuilder fullString = new StringBuilder();
-                for (Object message: messages) {
-                    fullString.append((String) message);
-                }
-                Debug.logWarning(fullString.toString(), module);
-
-                throw new IllegalArgumentException(fullString.toString());
-            }
-
-            return resultBool.booleanValue();
-        }
-    }
-
-    public static class IfRegexp extends MenuCondition {
-        protected FlexibleMapAccessor<Object> fieldAcsr;
-        protected FlexibleStringExpander exprExdr;
-
-        public IfRegexp(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
-            if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
-            this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            Object fieldVal = this.fieldAcsr.get(context);
-            String expr = this.exprExdr.expandString(context);
-            Pattern pattern = null;
-
-            try {
-                pattern = PatternFactory.createOrGetPerl5CompiledPattern(expr, true);
-            } catch (MalformedPatternException e) {
-                String errMsg = "Error in evaluation in if-regexp in screen: " + e.toString();
-                Debug.logError(e, errMsg, module);
-                throw new IllegalArgumentException(errMsg);
-            }
-
-            String fieldString = null;
-            try {
-                fieldString = (String) ObjectType.simpleTypeConvert(fieldVal, "String", null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true);
-            } catch (GeneralException e) {
-                Debug.logError(e, "Could not convert object to String, using empty String", module);
-            }
-            // always use an empty string by default
-            if (fieldString == null) fieldString = "";
-
-            PatternMatcher matcher = new Perl5Matcher();
-            return matcher.matches(fieldString, pattern);
-        }
-    }
-
-    public static class IfEmpty extends MenuCondition {
-        protected FlexibleMapAccessor<Object> fieldAcsr;
-
-        public IfEmpty(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
-            if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-            Object fieldVal = this.fieldAcsr.get(context);
-            return ObjectType.isEmpty(fieldVal);
-        }
-    }
-    public static class IfEntityPermission extends MenuCondition {
-        protected EntityPermissionChecker permissionChecker;
-
-        public IfEntityPermission(ModelMenuItem modelMenuItem, Element condElement) {
-            super (modelMenuItem, condElement);
-            this.permissionChecker = new EntityPermissionChecker(condElement);
-        }
-
-        @Override
-        public boolean eval(Map<String, Object> context) {
-
-            boolean passed = permissionChecker.runPermissionCheck(context);
-            return passed;
-        }
+    public FlexibleStringExpander getPassStyleExdr() {
+        return passStyleExdr;
     }
 }