You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mc...@apache.org on 2009/04/30 21:35:37 UTC

svn commit: r770409 - in /myfaces/core/branches/2_0_0: api/src/main/java/javax/faces/view/ impl/src/main/java/org/apache/myfaces/view/ impl/src/main/java/org/apache/myfaces/view/facelets/ impl/src/main/java/org/apache/myfaces/view/jsp/

Author: mconcini
Date: Thu Apr 30 19:35:37 2009
New Revision: 770409

URL: http://svn.apache.org/viewvc?rev=770409&view=rev
Log:
MYFACES-2206 - Implement javax.faces.view.ViewMetadata and associated methods

Added:
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/ViewMetadataImpl.java
Modified:
    myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/view/ViewMetadata.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
    myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java

Modified: myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/view/ViewMetadata.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/view/ViewMetadata.java?rev=770409&r1=770408&r2=770409&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/view/ViewMetadata.java (original)
+++ myfaces/core/branches/2_0_0/api/src/main/java/javax/faces/view/ViewMetadata.java Thu Apr 30 19:35:37 2009
@@ -19,7 +19,11 @@
 package javax.faces.view;
 
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
 
+import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewParameter;
 import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
@@ -38,7 +42,31 @@
     
     public static Collection<UIViewParameter> getViewParameters(UIViewRoot root)
     {
-        // TODO: IMPLEMENT HERE
-        return null;
+        LinkedList<UIViewParameter> result = new LinkedList<UIViewParameter>();
+        UIComponent metadataFacet = root.getFacet (UIViewRoot.METADATA_FACET_NAME);
+        Iterator<UIComponent> children;
+        
+        if (metadataFacet == null) {
+             // No metadata, so return an empty collection.
+             
+             return Collections.emptyList();
+        }
+        
+        // Iterate over all the children, keep only the view parameters.
+        
+        children = metadataFacet.getChildren().iterator();
+        
+        while (children.hasNext()) {
+             UIComponent component = children.next();
+             
+             if (component instanceof UIViewParameter) {
+                  result.add ((UIViewParameter) component);
+             }
+        }
+        
+        // TODO: does this need to be immutable?  Spec does not indicate either
+        // way.
+        
+        return Collections.unmodifiableCollection (result);
     }
 }

Added: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/ViewMetadataImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/ViewMetadataImpl.java?rev=770409&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/ViewMetadataImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/ViewMetadataImpl.java Thu Apr 30 19:35:37 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.view.ViewMetadata;
+
+/**
+ * This class represents the default implementation of javax.faces.view.ViewMetaData.
+ */
+
+public class ViewMetadataImpl extends ViewMetadata
+{
+    private String viewID;
+    
+    public ViewMetadataImpl (String viewID)
+    {
+        this.viewID = viewID;
+    }
+    
+    @Override
+    public UIViewRoot createMetadataView (FacesContext context)
+    {
+        // TODO implement.  This will require supporting Facelet parser/compiler logic
+        // to extract metadata.
+        
+        return null;
+    }
+
+    @Override
+    public String getViewId ()
+    {
+        return this.viewID;
+    }
+}

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java?rev=770409&r1=770408&r2=770409&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/facelets/FaceletViewDeclarationLanguage.java Thu Apr 30 19:35:37 2009
@@ -30,6 +30,7 @@
 
 import org.apache.myfaces.application.ViewHandlerSupport;
 import org.apache.myfaces.view.ViewDeclarationLanguageBase;
+import org.apache.myfaces.view.ViewMetadataImpl;
 
 /**
  * This class represents the abstraction of Facelets as a ViewDeclarationLanguage.
@@ -104,8 +105,19 @@
     @Override
     public ViewMetadata getViewMetadata(FacesContext context, String viewId)
     {
-        // TODO: IMPLEMENT HERE
-        return null;
+        if (context == null)
+        {
+            throw new NullPointerException ("context must not be null");
+        }
+        
+        if (viewId == null)
+        {
+            throw new NullPointerException ("viewId must not be null");
+        }
+        
+        // TODO: cache?
+        
+        return new ViewMetadataImpl (viewId);
     }
 
     /**

Modified: myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java?rev=770409&r1=770408&r2=770409&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java (original)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/org/apache/myfaces/view/jsp/JspViewDeclarationLanguage.java Thu Apr 30 19:35:37 2009
@@ -84,7 +84,21 @@
     @Override
     public ViewMetadata getViewMetadata(FacesContext context, String viewId)
     {
-        // TODO: IMPLEMENT HERE
+        // Not necessary given that this method always returns null, but staying true to
+        // the spec.
+        
+        if (context == null)
+        {
+            throw new NullPointerException ("context must not be null");
+        }
+        
+        if (viewId == null)
+        {
+            throw new NullPointerException ("viewId must not be null");
+        }
+        
+        // JSP impl must return null.
+        
         return null;
     }