You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2009/11/03 21:43:42 UTC

svn commit: r832546 - /myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java

Author: lu4242
Date: Tue Nov  3 20:43:41 2009
New Revision: 832546

URL: http://svn.apache.org/viewvc?rev=832546&view=rev
Log:
MYFACES-2371 NullPointerException on UIComponentClassicTagBase.getViewComponentIds() fixed on branch 2.0.x but not on branch 1.2.x (Thanks to Asuka Langley for note this issue)

Modified:
    myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java

Modified: myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java?rev=832546&r1=832545&r2=832546&view=diff
==============================================================================
--- myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java (original)
+++ myfaces/core/branches/1.2.x/api/src/main/java/javax/faces/webapp/UIComponentClassicTagBase.java Tue Nov  3 20:43:41 2009
@@ -778,7 +778,8 @@
     }
 
     /** Map of <ID,Tag> in the view */
-    private Map<String,Object> getViewComponentIds()
+    @SuppressWarnings("unchecked")
+    private Map<String, Object> getViewComponentIds()
     {
         Map<String, Object> requestMap = _facesContext.getExternalContext().getRequestMap();
         Map<String, Object> viewComponentIds;
@@ -786,12 +787,20 @@
         if (_parent == null)
         {
             // top level _componentInstance
-            viewComponentIds = new HashMap<String,Object>();
+            viewComponentIds = new HashMap<String, Object>();
             requestMap.put(VIEW_IDS, viewComponentIds);
         }
         else
         {
-            viewComponentIds = (Map<String, Object>) requestMap.get(VIEW_IDS);
+            viewComponentIds = (Map<String, Object>)requestMap.get(VIEW_IDS);
+            
+            // Check if null, this can happen if someone programatically tries to do an include of a 
+            // JSP fragment. This code will prevent NullPointerException from happening in such cases.
+            if (viewComponentIds == null)
+            {
+                viewComponentIds = new HashMap<String, Object>();
+                requestMap.put(VIEW_IDS, viewComponentIds);
+            }
         }
 
         return viewComponentIds;