You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gr...@apache.org on 2005/07/06 18:44:01 UTC

svn commit: r209479 - /myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java

Author: grantsmith
Date: Wed Jul  6 09:43:59 2005
New Revision: 209479

URL: http://svn.apache.org/viewcvs?rev=209479&view=rev
Log:
MYFACES-304: If a global message is added to the FacesContext (clientId is null), then someone calls getClientIdsWithMessages(), the Iterator that is returned should include null.  It does not;  it does correctly do this on the RI.

Also, from code inspection, it appears that getClientIdsWithMessages() will return a client ID twice if two messages are added against the same client ID.

Changes made:
  1. Simplified & improved getClientIdsWithMessages() to return an Iterator of a HashSet (thus unique) created from the _messageClientIds List.
  2. Removed the logic which stripped out the null.


Modified:
    myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java

Modified: myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java
URL: http://svn.apache.org/viewcvs/myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java?rev=209479&r1=209478&r2=209479&view=diff
==============================================================================
--- myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java (original)
+++ myfaces/impl/trunk/src/java/org/apache/myfaces/context/servlet/ServletFacesContextImpl.java Wed Jul  6 09:43:59 2005
@@ -45,7 +45,7 @@
  * @version $Revision$ $Date$
  */
 public class ServletFacesContextImpl
-    extends FacesContext
+        extends FacesContext
 {
     //~ Static fields/initializers -----------------------------------------------------------------
 
@@ -73,8 +73,8 @@
                                    PortletResponse portletResponse)
     {
         this(new PortletExternalContextImpl(portletContext,
-                                            portletRequest,
-                                            portletResponse));
+                portletRequest,
+                portletResponse));
     }
 
     public ServletFacesContextImpl(ServletContext servletContext,
@@ -82,14 +82,14 @@
                                    ServletResponse servletResponse)
     {
         this(new ServletExternalContextImpl(servletContext,
-                                            servletRequest,
-                                            servletResponse));
+                servletRequest,
+                servletResponse));
     }
 
     private ServletFacesContextImpl(ReleaseableExternalContext externalContext)
     {
         _application = ((ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY))
-                            .getApplication();
+                .getApplication();
         _renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         _externalContext = externalContext;
         FacesContext.setCurrentInstance(this);  //protected method, therefore must be called from here
@@ -124,43 +124,8 @@
             return NullIterator.instance();
         }
 
-        return new Iterator()
-            {
-                private int _next;
-                boolean     _nextFound;
-
-                public void remove()
-                {
-                    throw new UnsupportedOperationException(this.getClass().getName() + " UnsupportedOperationException");
-                }
-
-                public boolean hasNext()
-                {
-                    if (!_nextFound)
-                    {
-                        for (int len = _messageClientIds.size(); _next < len; _next++)
-                        {
-                            if (_messageClientIds.get(_next) != NULL_DUMMY)
-                            {
-                                _nextFound = true;
-                                break;
-                            }
-                        }
-                    }
-                    return _nextFound;
-                }
-
-                public Object next()
-                {
-                    if (hasNext())
-                    {
-                        _nextFound = false;
-                        return _messageClientIds.get(_next++);
-                    }
-
-                    throw new NoSuchElementException();
-                }
-            };
+        Set uniqueClientIds = new HashSet(_messageClientIds);
+        return uniqueClientIds.iterator();
     }
 
     public Iterator getMessages(String clientId)
@@ -188,19 +153,19 @@
 
     public RenderKit getRenderKit()
     {
-         if (getViewRoot() == null)
-         {
-             return null;
-         }
-
-         String renderKitId = getViewRoot().getRenderKitId();
-
-         if (renderKitId == null)
-         {
-             return null;
-         }
+        if (getViewRoot() == null)
+        {
+            return null;
+        }
+
+        String renderKitId = getViewRoot().getRenderKitId();
+
+        if (renderKitId == null)
+        {
+            return null;
+        }
 
-         return _renderKitFactory.getRenderKit(this, renderKitId);
+        return _renderKitFactory.getRenderKit(this, renderKitId);
     }
 
     public boolean getRenderResponse()