incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r467741 - in /incubator/adffaces/trunk/trinidad: trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/ trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/
Date Wed, 25 Oct 2006 19:24:25 GMT
Author: jwaldman
Date: Wed Oct 25 12:24:24 2006
New Revision: 467741

URL: http://svn.apache.org/viewvc?view=rev&rev=467741
Log:
ADFFACES-245 Changed XML Menu Model so that Custom Node attributes can only be used on itemNodes.
This is the patch + code review changes. Committed for Gary Kind.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java?view=diff&rev=467741&r1=467740&r2=467741
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
Wed Oct 25 12:24:24 2006
@@ -27,6 +27,7 @@
 import java.util.Map;
 
 import javax.faces.context.FacesContext;
+import javax.faces.el.PropertyNotFoundException;
 import javax.faces.el.PropertyResolver;
 import javax.faces.el.ValueBinding;
 import javax.faces.webapp.UIComponentTag;
@@ -369,7 +370,9 @@
 
   /**
    * Gets the list of custom properties from the node 
-   * and returns the value of propName.
+   * and returns the value of propName.  Node must be an itemNode.
+   * If it is not an itemNode, the node will not have any custom
+   * properties and null will be returned.
    * 
    * @param node Object used to get its list of custom properties
    * @param propName String name of the property whose value is desired
@@ -381,16 +384,24 @@
     if (node == null)
       return null;
       
-    FacesContext context = FacesContext.getCurrentInstance();
+    FacesContext context      = FacesContext.getCurrentInstance();
     PropertyResolver resolver = context.getApplication().getPropertyResolver();
+    String value              = null;
     
-    Map<String, String> propMap = 
-      (Map<String, String>) resolver.getValue(node, _CUSTOM_ATTR_LIST);
-   
-    if (propMap == null)
+    try
+    {
+      Map<String, String> propMap = 
+        (Map<String, String>) resolver.getValue(node, _CUSTOM_ATTR_LIST);
+        
+      value = propMap.get(propName);
+    }
+    catch (PropertyNotFoundException ex)
+    {
+      // if the node is not an itemNode, the node
+      // has no custom properties, so we simply
+      // return null 
       return null;
-      
-    String value = propMap.get(propName);
+    }
     
     // If it is an El expression, we must evaluate it
     // and return its value

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java?view=diff&rev=467741&r1=467740&r2=467741
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/ItemNode.java
Wed Oct 25 12:24:24 2006
@@ -17,6 +17,8 @@
 */
 package org.apache.myfaces.trinidadinternal.menu;
 
+import java.util.Map;
+
 import javax.faces.webapp.UIComponentTag;
 
 /**
@@ -412,7 +414,32 @@
      
     return value;
   }
-
+  
+  /**
+   * Get the Attributes containing the custom attributes on this node. This 
+   * needs to be public so that the menu model can get them.
+   * 
+   * @return Attributes list containing the custom attributes on this node
+   */
+  public Map<String, String> getCustomPropList()
+  {
+    return _customPropList;
+  }
+  
+  /**
+   * Set the list of custom attributes.
+   * 
+   * @param attrMap Map of attibute name/values for this node
+   * from MenuContentHandlerImpl
+   */
+  protected void setCustomPropList(Map<String, String> attrMap)
+  {
+    _customPropList = attrMap;
+  }
+  
+  // Map for Custom attributes (properties)
+  private Map<String, String> _customPropList = null;
+  
   private String _destination     = null;
   private String _targetFrame     = null;   
   private String _action          = null;

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java?view=diff&rev=467741&r1=467740&r2=467741
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
Wed Oct 25 12:24:24 2006
@@ -653,15 +653,14 @@
     String disabledStr = _getAndRemoveAttrValue(_DISABLED_ATTR);
     String readOnlyStr = _getAndRemoveAttrValue(_READONLY_ATTR);
     String accessKey   = _getAndRemoveAttrValue(_ACCESSKEY_ATTR);
-    String labelAndAccessKey   = _getAndRemoveAttrValue(_LABEL_AND_ACCESSKEY_ATTR);
+    String labelAndAccessKey = _getAndRemoveAttrValue(_LABEL_AND_ACCESSKEY_ATTR);
     String id          = _getAndRemoveAttrValue(_ID_ATTR);
     String visibleStr  = _getAndRemoveAttrValue(_VISIBLE_ATTR);
     
-    MenuNode menuNode = 
-        (  _currentNodeStyle == MenuConstants.NODE_STYLE_ITEM
-         ? _createItemNode()
-         : _createGroupNode()
-        );
+    MenuNode menuNode = (  _currentNodeStyle == MenuConstants.NODE_STYLE_ITEM
+                         ? _createItemNode()
+                         : _createGroupNode()
+                        );
   
     // Set the generic attributes
     menuNode.setLabel(label);
@@ -676,12 +675,6 @@
     if (labelAndAccessKey != null)
       menuNode.setLabelAndAccessKey(labelAndAccessKey);
 
-    // Set the Any Attributes Attrlist
-    if (_attrMap.size() > 0)
-    {
-      menuNode.setCustomPropList(_attrMap);
-    }
-    
     return menuNode;
   }
   
@@ -731,6 +724,12 @@
     // Former destination node attrs
     itemNode.setDestination(destination);
     itemNode.setTargetFrame(targetFrame);
+    
+    // Set the Any Attributes Attrlist
+    if (_attrMap.size() > 0)
+    {
+      itemNode.setCustomPropList(_attrMap);
+    }
     
     return itemNode;
   }

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java?view=diff&rev=467741&r1=467740&r2=467741
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuNode.java
Wed Oct 25 12:24:24 2006
@@ -525,39 +525,6 @@
   }
   
   /**
-   * Get the value of a custom attribute.  This needs to be
-   * public so that the menu model can call into the node
-   * to get the value of a custom attribute.
-   * 
-   * @param name String name of the custom attribute
-   * @return Object value of the matching node
-   */
-  public Object getCustomProperty(String name)
-  {
-    String value = _customPropList.get(name);
-    
-    if (   value != null
-        && UIComponentTag.isValueReference(value)
-       )
-     {
-       return MenuUtils.getBoundValue(value);
-     }
-     
-    return value;
-  }
-  
-  /**
-   * Get the Attributes containing the custom attributes on this node. This 
-   * needs to be public so that the menu model can get them.
-   * 
-   * @return Attributes list containing the custom attributes on this node
-   */
-  public Map<String, String> getCustomPropList()
-  {
-    return _customPropList;
-  }
-  
-  /**
    * Get the top-level, root menu model Request Map Key.
    * 
    * @return root, top-level XMLMenuModel's Request Map Key.
@@ -587,17 +554,6 @@
   }
 
   /**
-   * Set the list of custom attributes.
-   * 
-   * @param attrMap Map of attibute name/values for this node
-   * from MenuContentHandlerImpl
-   */
-  protected void setCustomPropList(Map<String, String> attrMap)
-  {
-    _customPropList = attrMap;
-  }
-  
-  /**
    * setResBundleKey - sets the name of the resource bundle used in 
    * obtaining the node's label text. Used, along with the handerId, 
    * to identify and get a string from the proper resource bundle.
@@ -817,9 +773,6 @@
   private boolean        _labelAndAccessKeyEL = false;
   private String         _labelAndAccessKey   = null;
   private String         _defaultFocusPathStr = null;
-  
-  // Map for Custom attributes (properties)
-  private Map<String, String> _customPropList = null;
   
   // Root Menu model's Request Map Key
   private String _rootModelKey  = null;



Mime
View raw message