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/09/03 23:39:44 UTC

svn commit: r811138 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core: CoreLibrary.java ViewMetadataHandler.java

Author: lu4242
Date: Thu Sep  3 21:39:44 2009
New Revision: 811138

URL: http://svn.apache.org/viewvc?rev=811138&view=rev
Log:
MYFACES-2322 Implement <f:metadata> tag handler

Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java   (with props)
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreLibrary.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreLibrary.java?rev=811138&r1=811137&r2=811138&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreLibrary.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/CoreLibrary.java Thu Sep  3 21:39:44 2009
@@ -21,6 +21,7 @@
 import javax.faces.component.UIParameter;
 import javax.faces.component.UISelectItem;
 import javax.faces.component.UISelectItems;
+import javax.faces.component.UIViewParameter;
 import javax.faces.convert.DateTimeConverter;
 import javax.faces.convert.NumberConverter;
 import javax.faces.validator.DoubleRangeValidator;
@@ -66,6 +67,8 @@
 
         this.addTagHandler("loadBundle", LoadBundleHandler.class);
 
+        this.addTagHandler("metadata", ViewMetadataHandler.class);
+        
         this.addComponent("param", UIParameter.COMPONENT_TYPE, null);
 
         this.addTagHandler("phaseListener", PhaseListenerHandler.class);
@@ -91,6 +94,8 @@
         this.addTagHandler("valueChangeListener", ValueChangeListenerHandler.class);
 
         this.addTagHandler("view", ViewHandler.class);
+        
+        this.addComponent("viewParam", UIViewParameter.COMPONENT_TYPE, null);
 
         this.addComponent("verbatim", "javax.faces.HtmlOutputText", "javax.faces.Text", VerbatimHandler.class);
     }

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java?rev=811138&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java (added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java Thu Sep  3 21:39:44 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.facelets.tag.jsf.core;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.component.UIViewRoot;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+/**
+ * Defines the view metadata. It is expected that this tag contains only
+ * one or many f:viewParam tags.
+ * 
+ * @author Leonardo Uribe (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@JSFFaceletTag(name="f:metadata")
+public final class ViewMetadataHandler extends TagHandler
+{
+
+    public ViewMetadataHandler(TagConfig config)
+    {
+        super(config);
+    }
+
+    @Override
+    public void apply(FaceletContext ctx, UIComponent parent)
+            throws IOException
+    {
+        if (parent == null)
+        {
+            throw new TagException(this.tag, "Parent UIComponent was null");
+        }
+        if (! (parent instanceof UIViewRoot) )
+        {
+            throw new TagException(this.tag, "Parent UIComponent "+parent.getId()+" should be instance of UIViewRoot");
+        }
+        UIComponent metadataFacet = parent.getFacet(UIViewRoot.METADATA_FACET_NAME);
+        if (metadataFacet == null)
+        {
+            metadataFacet = ctx.getFacesContext().
+                getApplication().createComponent(UIPanel.COMPONENT_TYPE);
+            metadataFacet.setId(UIViewRoot.METADATA_FACET_NAME);
+            parent.getChildren().add(metadataFacet);
+        }
+        this.nextHandler.apply(ctx, metadataFacet);
+    }
+}

Propchange: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/core/ViewMetadataHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL