Author: craigmcc
Date: Sat Apr 23 20:48:32 2005
New Revision: 164443

URL: http://svn.apache.org/viewcvs?rev=164443&view=rev
Log:
Support value binding evaluation on the "managedBeanName" property.  The
original patch also supported this on the "jsfid" property, but I've commented
that out for consistency with the way standard JSF components handle the
"id" property -- it is not value binding enabled, to avoid potential scripting
problems.

Modified:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java?rev=164443&r1=164442&r2=164443&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/taglib/ClayTag.java
 Sat Apr 23 20:48:32 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004-2005 The Apache Software Foundation.
- * 
+ *
  * Licensed 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.
@@ -17,6 +17,8 @@
 package org.apache.shale.clay.taglib;
 
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
 import javax.faces.webapp.UIComponentTag;
 
 import org.apache.commons.logging.Log;
@@ -25,53 +27,53 @@
 
 public class ClayTag extends UIComponentTag {
     
-       /**
-        * <p>Common logging utility instance </p>
-        */
+    /**
+     * <p>Common logging utility instance </p>
+     */
     public static Log log = LogFactory.getLog(ClayTag.class);
     
-       /**
-        * <p>Represents the meta-component to build the subtree on.</p>
-        */
+    /**
+     * <p>Represents the meta-component to build the subtree on.</p>
+     */
     private String jsfid = null;
     
-       /**
-        * <p>The name of the managed bean instance in the faces config file 
that
-        * should be bound to this view composition.  The literal 
"managed-bean-name" 
-        * in the component metadata will be replaced with this value before 
the 
-        * binding of the expression is created.
-        * </p>
-        */
+    /**
+     * <p>The name of the managed bean instance in the faces config file that
+     * should be bound to this view composition.  The literal 
"managed-bean-name"
+     * in the component metadata will be replaced with this value before the
+     * binding of the expression is created.
+     * </p>
+     */
     private String managedBeanName = null;
     
-       /**
-        * <p>A method event that conforms to the standard 
<code>validator</code>
-        * attribute.  This event will get fired before the sub component tree 
is 
-        * build.
-        * </p>
-        */
+    /**
+     * <p>A method event that conforms to the standard <code>validator</code>
+     * attribute.  This event will get fired before the sub component tree is
+     * build.
+     * </p>
+     */
     private String shapeValidator = null;
     
-       /**
-        * <p>Returns the expression literal defining the validator event method
-        *  binding.
-        *  </p>
-        */
+    /**
+     * <p>Returns the expression literal defining the validator event method
+     *  binding.
+     *  </p>
+     */
     public String getShapeValidator() {
         return shapeValidator;
     }
     
-       /**
-        * <p>Sets the expression literal defining the validator event method 
binding.
-        * </p>
-        * 
-        * @param shapeValidator <code>String</code> validator binding 
expression
-        */
+    /**
+     * <p>Sets the expression literal defining the validator event method 
binding.
+     * </p>
+     *
+     * @param shapeValidator <code>String</code> validator binding expression
+     */
     public void setShapeValidator(String shapeValidator) {
         this.shapeValidator = shapeValidator;
     }
     
-        
+    
     /**
      * <p>Gets the display Element identifier to be rendered.</p>
      */
@@ -82,7 +84,7 @@
     /**
      * <p>Sets the identifier defining component metadata.
      * </p>
-     * 
+     *
      * @param jsfid <code>String</code> sets the component element to be 
rendered
      */
     public void setJsfid(String jsfid) {
@@ -90,9 +92,9 @@
     }
     
     /**
-     * <p>Gets the name of the managed bean that is dynamically resolved 
-     * using a token replacement before binding the value expression. 
-     * If not explicitly set, it will default to the literal 
<code>UNKNOWN</code> 
+     * <p>Gets the name of the managed bean that is dynamically resolved
+     * using a token replacement before binding the value expression.
+     * If not explicitly set, it will default to the literal 
<code>UNKNOWN</code>
      * </p>
      */
     public String getManagedBeanName() {
@@ -108,55 +110,84 @@
      * string "managed-bean-name" is replaced with the value of this
      * property.
      * </p>
-     *            
-     * @param managedBeanName <code>String</code>            
+     *
+     * @param managedBeanName <code>String</code>
      */
     public void setManagedBeanName(String managedBeanName) {
         this.managedBeanName = managedBeanName;
     }
     
-       
-    /** 
+    
+    /**
      * <p> Returns the logical component name registered in the faces config
      * for the [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} 
component.
      * </p>
      *
      * @see javax.faces.webapp.UIComponentTag#getComponentType()
-    */
+     */
     public String getComponentType() {
         return "org.apache.shale.clay.component.Clay";
     }
     
     /**
-    * <p>Returns the render registered for the component.  The 
-    * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component 
doesn't 
-    * have a render because the component invokes the rendering of
-    * it's children.  
-    * </p>
-    *
-    * @see javax.faces.webapp.UIComponentTag#getRendererType()
-    */
+     * <p>Returns the render registered for the component.  The
+     * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component 
doesn't
+     * have a render because the component invokes the rendering of
+     * it's children.
+     * </p>
+     *
+     * @see javax.faces.webapp.UIComponentTag#getRendererType()
+     */
     public String getRendererType() {
         return null;
     }
     
-       /**
-        *  <p>This method is invoked by the super and its purpose it
-        *  to push tag attributes to corresponding component property 
-        *  values.
-        *  </p>
-        *  
-        * @param component [EMAIL PROTECTED] UIComponent} instance of [EMAIL 
PROTECTED] org.apache.shale.clay.component.Clay}
-        */
+    /**
+     *  <p>This method is invoked by the super and its purpose it
+     *  to push tag attributes to corresponding component property
+     *  values.
+     *  </p>
+     *
+     * @param component [EMAIL PROTECTED] UIComponent} instance of [EMAIL 
PROTECTED] org.apache.shale.clay.component.Clay}
+     */
     protected void setProperties(UIComponent component) {
         super.setProperties(component);
         
         Clay c = (Clay) component;
-        if (getJsfid() != null)
+        FacesContext facesContext = getFacesContext();
+        
+        if (getJsfid() != null) {
+
+            /* FIXME - "id" attributes in JSF components are not value binding 
enabled,
+             * so do not support it here either
+            if(isValueReference(getJsfid())) {
+                ValueBinding valueBinding = 
facesContext.getApplication().createValueBinding(getJsfid());
+                Object value = valueBinding.getValue(facesContext);
+                c.setJsfid((value != null) ? value.toString() : null);
+                
+            } else {
+                c.setJsfid(getJsfid());
+            }
+             */
             c.setJsfid(getJsfid());
+            
+        }
+        
         
-        if (getManagedBeanName() != null)
+        if (getManagedBeanName() != null) {
             c.setManagedBeanName(getManagedBeanName());
+            
+            if(isValueReference(getManagedBeanName())) {
+                ValueBinding valueBinding = 
facesContext.getApplication().createValueBinding(getManagedBeanName());
+                Object value = valueBinding.getValue(facesContext);
+                c.setManagedBeanName((value != null) ? value.toString() : 
null);
+                
+            } else {
+                c.setManagedBeanName(getManagedBeanName());
+            }
+            
+        }
+        
         
         if (getShapeValidator() != null)
             c.setShapeValidator(getShapeValidator());



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to