You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/08/21 00:03:41 UTC
svn commit: r567847 - in
/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/
Author: jwaldman
Date: Mon Aug 20 15:03:38 2007
New Revision: 567847
URL: http://svn.apache.org/viewvc?rev=567847&view=rev
Log:
Jira issue TRINIDAD-102 Attempt to get the value of a custom property from a node that has no custom properties causes NPE
Added check for null to getCustomProperty in XMLMenuModel.java
JIRA issue TRINIDAD-101 Menu Model is not created if its tree is empty
Add code to create menu model if tree is empty in endDocument() in MenuContentHandlerImpl.java
Committed to faces-1_2_1-070726 branch for Gary Kind.
Modified:
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java?rev=567847&r1=567846&r2=567847&view=diff
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/model/XMLMenuModel.java Mon Aug 20 15:03:38 2007
@@ -483,6 +483,12 @@
Map<String, String> propMap =
(Map<String, String>) resolver.getValue(elContext,
node, _CUSTOM_ATTR_LIST);
+
+ // Need to check to see if propMap is null. If there are
+ // no custom properties for this itemNode, there will be
+ // no propMap. See MenuContentHandler._createItemNode().
+ if (propMap == null)
+ return null;
value = propMap.get(propName);
}
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java?rev=567847&r1=567846&r2=567847&view=diff
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/menu/MenuContentHandlerImpl.java Mon Aug 20 15:03:38 2007
@@ -348,39 +348,54 @@
@Override
public void endDocument()
{
- _menuList = _menuNodes.get(0);
-
- // Create the treeModel
- ChildPropertyTreeModel treeModel =
- new ChildPropertyTreeModel(_menuList, "children");
-
- // Put it in the map
- _treeModelMap.put(_currentTreeModelMapKey, treeModel);
-
- // If Model is the Root, then build Model's hashmaps
- // and set them on the Root Model.
- XMLMenuModel rootModel = getRootModel();
-
- if (rootModel == getModel())
+ if (_menuNodes.isEmpty())
{
- _viewIdFocusPathMap = new HashMap<String,List<Object>>();
- _nodeFocusPathMap = new HashMap<Object, List<Object>>();
- _idNodeMap = new HashMap<String, Object>();
- Object oldPath = treeModel.getRowKey();
-
- treeModel.setRowKey(null);
-
- // Populate the maps
- _addToMaps(treeModel, _viewIdFocusPathMap, _nodeFocusPathMap, _idNodeMap);
+ // Empty tree is created to prevent
+ // later NPEs if menu model methods are called.
+ _LOG.warning ("CREATE_TREE_WARNING: Empty Tree!");
- // Cache the maps. There is a possibility of multiple
- // root models so we must cache the maps on a per root model
- // basis.
- _viewIdFocusPathMapMap.put(_currentTreeModelMapKey, _viewIdFocusPathMap);
- _nodeFocusPathMapMap.put(_currentTreeModelMapKey, _nodeFocusPathMap);
- _idNodeMapMap.put(_currentTreeModelMapKey, _idNodeMap);
+ // Create empty treeModel
+ ChildPropertyTreeModel treeModel = new ChildPropertyTreeModel();
+
+ // Put it in the map
+ _treeModelMap.put(_currentTreeModelMapKey, treeModel);
+ }
+ else
+ {
+ _menuList = _menuNodes.get(0);
+
+ // Create the treeModel
+ ChildPropertyTreeModel treeModel =
+ new ChildPropertyTreeModel(_menuList, "children");
+
+ // Put it in the map
+ _treeModelMap.put(_currentTreeModelMapKey, treeModel);
+
+ // If Model is the Root, then build Model's hashmaps
+ // and set them on the Root Model.
+ XMLMenuModel rootModel = getRootModel();
- treeModel.setRowKey(oldPath);
+ if (rootModel == getModel())
+ {
+ _viewIdFocusPathMap = new HashMap<String,List<Object>>();
+ _nodeFocusPathMap = new HashMap<Object, List<Object>>();
+ _idNodeMap = new HashMap<String, Object>();
+ Object oldPath = treeModel.getRowKey();
+
+ treeModel.setRowKey(null);
+
+ // Populate the maps
+ _addToMaps(treeModel, _viewIdFocusPathMap, _nodeFocusPathMap, _idNodeMap);
+
+ // Cache the maps. There is a possibility of multiple
+ // root models so we must cache the maps on a per root model
+ // basis.
+ _viewIdFocusPathMapMap.put(_currentTreeModelMapKey, _viewIdFocusPathMap);
+ _nodeFocusPathMapMap.put(_currentTreeModelMapKey, _nodeFocusPathMap);
+ _idNodeMapMap.put(_currentTreeModelMapKey, _idNodeMap);
+
+ treeModel.setRowKey(oldPath);
+ }
}
}