Author: gvanmatre
Date: Thu Nov 17 20:26:10 2005
New Revision: 345441

URL: http://svn.apache.org/viewcvs?rev=345441&view=rev
Log:
Added postprocess command interceptors for the Clay component matching the 
preprocess.  Added an extension to the LookupCommand that is more forgiving 
when a catalog is not registered.

Added:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
   (with props)
Modified:
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/shale-clay-config.xml
    
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
   (contents, props changed)

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/shale-clay-config.xml
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/shale-clay-config.xml?rev=345441&r1=345440&r2=345441&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/shale-clay-config.xml
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/shale-clay-config.xml
 Thu Nov 17 20:26:10 2005
@@ -24,7 +24,7 @@
 
   <chain           name="addComponent">
 
-    <command className   = "org.apache.commons.chain.generic.LookupCommand"
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
              catalogName = "clayCustomization"
              name        = "preprocessAddComponent"
              optional    = "true"/>
@@ -34,7 +34,13 @@
              name        = "createComponent"
              optional    = "false"/>
              
-    <command  
className="org.apache.shale.clay.component.chain.AssignChildrenCommand"/>
+    <command  
className="org.apache.shale.clay.component.chain.AssignChildrenCommand"/>
+    
+     <command className   = 
"org.apache.shale.clay.utils.PluggableLookupCommand"
+              catalogName = "clayCustomization"
+              name        = "postprocessAddComponent"
+              optional    = "true"/>
+    
                
   </chain>
 
@@ -53,54 +59,72 @@
 
   <chain           name="addConverter">
 
-    <command className   = "org.apache.commons.chain.generic.LookupCommand"
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
              catalogName = "clayCustomization"
              name        = "preprocessAddConverter"
              optional    = "true"/>
 
     <command  
className="org.apache.shale.clay.component.chain.CreateConverterCommand"/>
     <command  
className="org.apache.shale.clay.component.chain.AssignPropertiesCommand"/>
+
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
+              catalogName = "clayCustomization"
+              name        = "postprocessAddConverter"
+              optional    = "true"/>
 
   </chain>
 
 
   <chain           name="addValidator">
 
-    <command className   = "org.apache.commons.chain.generic.LookupCommand"
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
              catalogName = "clayCustomization"
              name        = "preprocessAddValidator"
              optional    = "true"/>
 
     <command  
className="org.apache.shale.clay.component.chain.CreateValidatorCommand"/>
     <command  
className="org.apache.shale.clay.component.chain.AssignPropertiesCommand"/>
+
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
+             catalogName = "clayCustomization"
+             name        = "postprocessAddValidator"
+             optional    = "true"/>
 
   </chain>
 
 
   <chain           name="addValueChangeListener">
 
-    <command className   = "org.apache.commons.chain.generic.LookupCommand"
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
              catalogName = "clayCustomization"
              name        = "preprocessAddValueChangeListener"
              optional    = "true"/>
-
 
     <command  
className="org.apache.shale.clay.component.chain.CreateValueChangeListenerCommand"/>
     <command  
className="org.apache.shale.clay.component.chain.AssignPropertiesCommand"/>
+
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
+             catalogName = "clayCustomization"
+             name        = "postprocessAddValueChangeListener"
+             optional    = "true"/>
 
   </chain>
 
 
   <chain           name="addActionListener">
 
-    <command className   = "org.apache.commons.chain.generic.LookupCommand"
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
              catalogName = "clayCustomization"
              name        = "preprocessAddActionListener"
              optional    = "true"/>
-
 
     <command  
className="org.apache.shale.clay.component.chain.CreateActionListenerCommand"/>
     <command  
className="org.apache.shale.clay.component.chain.AssignPropertiesCommand"/>
+
+    <command className   = "org.apache.shale.clay.utils.PluggableLookupCommand"
+             catalogName = "clayCustomization"
+             name        = "postprocessAddActionListener"
+             optional    = "true"/>
 
   </chain>
 

Modified: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java?rev=345441&r1=345440&r2=345441&view=diff
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 (original)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
 Thu Nov 17 20:26:10 2005
@@ -1,292 +1,292 @@
-/*
- * Copyright 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * $Id$
- */
-
-package org.apache.shale.clay.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.shale.clay.component.Clay;
-import org.apache.shale.clay.config.ClayConfigureListener;
-import org.apache.shale.clay.config.beans.AttributeBean;
-import org.apache.shale.clay.config.beans.ComponentBean;
-import org.apache.shale.faces.ShaleConstants;
-import org.apache.shale.util.Messages;
-import org.apache.shale.util.Tags;
-
-/**
- * <p>This class is a mix of runtime utilities for the 
- * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component.  
- * It is loaded as a managed bean in application scope by 
- * the clay component's registration.</p>  
- */
-public class ClayAmalgam {
-
-    /**
-     * <p>Commons logging utility object static instance.</p>
-     */
-    private static Log log;
-    static {
-        log = LogFactory.getLog(ClayAmalgam.class);
-    }
-    
-    /**
-     * <p>Message resources for this class.</p>
-     */
-    private static Messages messages = new 
Messages("org.apache.shale.clay.Bundle",
-            ClayConfigureListener.class.getClassLoader());
-    
-    /**
-     * <p>Replaces tokens in the <code>document</code> with 
-     * matching tokens in the <code>context</code>.</p>
-     */
-    protected void replace(StringBuffer document, Map context) {
-
-        Iterator di = context.entrySet().iterator();
-        while (di.hasNext()) {
-            Map.Entry e = (Map.Entry) di.next();
-
-            String name = (String) e.getKey();
-            String value = (String) e.getValue();
-
-            for (int i = 0; i <= (document.length() - name.length()); i++) {
-                String token = document.substring(i, i + name.length());
-                if (token.compareToIgnoreCase(name) == 0) {
-                    document.delete(i, i + name.length());
-                    document.insert(i, value);
-                }
-
-                token = null;
-            }
-
-            e = null;
-            name = null;
-            value = null;
-        }
-        di = null;
-
-    }
-
-    /**
-     * <p>Mapping used to encode special characters.</p>
-     */
-    private static TreeMap encodeMap = null;
-    static {
-        encodeMap = new TreeMap();
-        encodeMap.put("'", "&#39;");
-        encodeMap.put("&", "&amp;");
-        encodeMap.put("<", "&lt;");
-        encodeMap.put(">", "&gt;");
-        encodeMap.put("}", "&#125;");
-        encodeMap.put("{", "&#123;");  
-    }
-
-    /**
-     * <p>Encodes a string value using the <code>encodeMap</code>.</p>
-     */
-    public String encode(String value) {
-        StringBuffer buff = new StringBuffer(value);
-        replace(buff, encodeMap);
-        return buff.toString();
-    }
-
-    /**
-     * <p>Mapping used to decode special characters.</p>
-     */
-    private static TreeMap decodeMap = null;
-    static {
-        decodeMap = new TreeMap();
-        decodeMap.put("&quot;", "\"");
-        decodeMap.put("&#39;", "'");
-        decodeMap.put("&amp;", "&");
-        decodeMap.put("&lt;", "<");
-        decodeMap.put("&gt;", ">");
-        decodeMap.put("&#125;", "}");
-        decodeMap.put("&#123;", "{");        
-    }
-
-    /**
-     * <p>Decodes a string value using the <code>decodeMap</code>.</p>
-     */
-    public String decode(String value) {
-        StringBuffer buff = new StringBuffer(value);
-        replace(buff, decodeMap);
-        return buff.toString();
-    }
-    
-  
-    /**
-     * <p>This is a method binding "validator" signature that can be bound to 
the 
-     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
-     * component.  It expects that the <code>value</code> attribute will 
contain an html string that
-     * represents an HTML node.  The value will be encode or decode depending 
on the value of the
-     * <code>escapeXml</code> optional attribute.  The default is "false". 
</p>   
-     */
-    public void clayOut(javax.faces.context.FacesContext context,
-            javax.faces.component.UIComponent component,
-            java.lang.Object displayElementRoot) {
-       
-        Tags tagUtils = (Tags) context.getApplication().getVariableResolver()
-                                      .resolveVariable(context, 
ShaleConstants.TAG_UTILITY_BEAN);
-        if (tagUtils == null)
-            throw new 
NullPointerException(messages.getMessage("clay.null.tagUtils"));
-
-        
-        if (!(displayElementRoot instanceof ComponentBean) ||
-                !(component instanceof Clay)) {
-            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayOut"}));    
-        }
-        
-        ComponentBean text = (ComponentBean) displayElementRoot;
-        Clay clay = (Clay) component;
-        String value = (String) clay.getAttributes().get("value");
-        value = tagUtils.eval(value);
-        if (value == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayOut"}));    
-        }
-        
-        boolean escapeXml = false;
-        String tmp = (String) clay.getAttributes().get("escapeXml");
-        if (tmp != null) {
-           escapeXml =  tagUtils.evalBoolean(tmp).booleanValue();
-        }
-        
-        if (!escapeXml)
-            value = decode(value);
-        else 
-            value = encode(value);
-        
-        text.setJsfid("outputText");
-        text.setComponentType("javax.faces.HtmlOutputText");
-        
-        // add a value attribute
-        AttributeBean attr = new AttributeBean();
-        attr.setName("value");
-        attr.setValue(value);
-        text.addAttribute(attr);
-        
-        // add a escape attribute
-        attr = new AttributeBean();
-        attr.setName("escape");
-        attr.setValue(Boolean.FALSE.toString());
-        text.addAttribute(attr);
-        
-        // add a isTransient attribute
-        attr = new AttributeBean();
-        attr.setName("isTransient");
-        attr.setValue(Boolean.TRUE.toString());
-        text.addAttribute(attr);
-        
-    }
-
-    /**
-     * <p>This is a method binding "validator" signature that can be bound to 
the 
-     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
-     * component.  It expects that the <code>url</code> attribute will contain 
the file to import
-     * relative to the web context root. The content of the file will be 
encode or decode depending 
-     * on the value of the <code>escapeXml</code> optional attribute.  The 
default doesn't apply
-     * any encoding. </p>   
-     */
-    public void clayImport(javax.faces.context.FacesContext context,
-            javax.faces.component.UIComponent component,
-            java.lang.Object displayElementRoot) {
-        
-        Tags tagUtils = (Tags) context.getApplication().getVariableResolver()
-                                      .resolveVariable(context, 
ShaleConstants.TAG_UTILITY_BEAN);
-        if (tagUtils == null)
-            throw new 
NullPointerException(messages.getMessage("clay.null.tagUtils"));
-
-        
-        if (!(displayElementRoot instanceof ComponentBean) ||
-                !(component instanceof Clay)) {
-            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayImport"}));    
-        }
-        
-        ComponentBean text = (ComponentBean) displayElementRoot;
-        Clay clay = (Clay) component;
-        String url = (String) clay.getAttributes().get("url");
-        if (url == null) {
-            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] {"url", 
"clayImport"}));    
-        }
-        url = tagUtils.eval(url);
-        
-        boolean escapeXml = true;
-        String escAttribute = (String) clay.getAttributes().get("escapeXml");
-        if (escAttribute != null) {
-           escapeXml =  tagUtils.evalBoolean(escAttribute).booleanValue();
-        }
-                
-        StringBuffer value = new StringBuffer();
-        
-        InputStream in = null;
-        try {
-            in = context.getExternalContext().getResourceAsStream(url);
-            int c = 0;
-            done: while (true) {
-                c = in.read();
-                if (c > -1)
-                    value.append((char) c);
-                else
-                    break done;
-                
-            }
-        } catch (IOException e) {
-            throw new 
RuntimeException(messages.getMessage("invalid.attribute", new Object[] {"url", 
"clayImport"}));
-        } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {}
-            }   
-            
-        }
-        
-        if (escAttribute != null) {
-           if (!escapeXml)
-               replace(value, decodeMap);
-           else 
-               replace(value, encodeMap);
-        }
-           
-        text.setJsfid("outputText");
-        text.setComponentType("javax.faces.HtmlOutputText");
-        
-        // add a value attribute
-        AttributeBean attr = new AttributeBean();
-        attr.setName("value");
-        attr.setValue(value.toString());
-        text.addAttribute(attr);
-        
-        // add a escape attribute
-        attr = new AttributeBean();
-        attr.setName("escape");
-        attr.setValue(Boolean.FALSE.toString());
-        text.addAttribute(attr);
-        
-        // add a isTransient attribute
-        attr = new AttributeBean();
-        attr.setName("isTransient");
-        attr.setValue(Boolean.TRUE.toString());
-        text.addAttribute(attr);
-    }   
-}
+/*
+ * Copyright 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.clay.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.component.Clay;
+import org.apache.shale.clay.config.ClayConfigureListener;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.faces.ShaleConstants;
+import org.apache.shale.util.Messages;
+import org.apache.shale.util.Tags;
+
+/**
+ * <p>This class is a mix of runtime utilities for the 
+ * [EMAIL PROTECTED] org.apache.shale.clay.component.Clay} component.  
+ * It is loaded as a managed bean in application scope by 
+ * the clay component's registration.</p>  
+ */
+public class ClayAmalgam {
+
+    /**
+     * <p>Commons logging utility object static instance.</p>
+     */
+    private static Log log;
+    static {
+        log = LogFactory.getLog(ClayAmalgam.class);
+    }
+    
+    /**
+     * <p>Message resources for this class.</p>
+     */
+    private static Messages messages = new 
Messages("org.apache.shale.clay.Bundle",
+            ClayConfigureListener.class.getClassLoader());
+    
+    /**
+     * <p>Replaces tokens in the <code>document</code> with 
+     * matching tokens in the <code>context</code>.</p>
+     */
+    protected void replace(StringBuffer document, Map context) {
+
+        Iterator di = context.entrySet().iterator();
+        while (di.hasNext()) {
+            Map.Entry e = (Map.Entry) di.next();
+
+            String name = (String) e.getKey();
+            String value = (String) e.getValue();
+
+            for (int i = 0; i <= (document.length() - name.length()); i++) {
+                String token = document.substring(i, i + name.length());
+                if (token.compareToIgnoreCase(name) == 0) {
+                    document.delete(i, i + name.length());
+                    document.insert(i, value);
+                }
+
+                token = null;
+            }
+
+            e = null;
+            name = null;
+            value = null;
+        }
+        di = null;
+
+    }
+
+    /**
+     * <p>Mapping used to encode special characters.</p>
+     */
+    private static TreeMap encodeMap = null;
+    static {
+        encodeMap = new TreeMap();
+        encodeMap.put("'", "&#39;");
+        encodeMap.put("&", "&amp;");
+        encodeMap.put("<", "&lt;");
+        encodeMap.put(">", "&gt;");
+        encodeMap.put("}", "&#125;");
+        encodeMap.put("{", "&#123;");  
+    }
+
+    /**
+     * <p>Encodes a string value using the <code>encodeMap</code>.</p>
+     */
+    public String encode(String value) {
+        StringBuffer buff = new StringBuffer(value);
+        replace(buff, encodeMap);
+        return buff.toString();
+    }
+
+    /**
+     * <p>Mapping used to decode special characters.</p>
+     */
+    private static TreeMap decodeMap = null;
+    static {
+        decodeMap = new TreeMap();
+        decodeMap.put("&quot;", "\"");
+        decodeMap.put("&#39;", "'");
+        decodeMap.put("&amp;", "&");
+        decodeMap.put("&lt;", "<");
+        decodeMap.put("&gt;", ">");
+        decodeMap.put("&#125;", "}");
+        decodeMap.put("&#123;", "{");        
+    }
+
+    /**
+     * <p>Decodes a string value using the <code>decodeMap</code>.</p>
+     */
+    public String decode(String value) {
+        StringBuffer buff = new StringBuffer(value);
+        replace(buff, decodeMap);
+        return buff.toString();
+    }
+    
+  
+    /**
+     * <p>This is a method binding "validator" signature that can be bound to 
the 
+     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
+     * component.  It expects that the <code>value</code> attribute will 
contain an html string that
+     * represents an HTML node.  The value will be encode or decode depending 
on the value of the
+     * <code>escapeXml</code> optional attribute.  The default is "false". 
</p>   
+     */
+    public void clayOut(javax.faces.context.FacesContext context,
+            javax.faces.component.UIComponent component,
+            java.lang.Object displayElementRoot) {
+       
+        Tags tagUtils = (Tags) context.getApplication().getVariableResolver()
+                                      .resolveVariable(context, 
ShaleConstants.TAG_UTILITY_BEAN);
+        if (tagUtils == null)
+            throw new 
NullPointerException(messages.getMessage("clay.null.tagUtils"));
+
+        
+        if (!(displayElementRoot instanceof ComponentBean) ||
+                !(component instanceof Clay)) {
+            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayOut"}));    
+        }
+        
+        ComponentBean text = (ComponentBean) displayElementRoot;
+        Clay clay = (Clay) component;
+        String value = (String) clay.getAttributes().get("value");
+        value = tagUtils.eval(value);
+        if (value == null) {
+            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] 
{"value", "clayOut"}));    
+        }
+        
+        boolean escapeXml = false;
+        String tmp = (String) clay.getAttributes().get("escapeXml");
+        if (tmp != null) {
+           escapeXml =  tagUtils.evalBoolean(tmp).booleanValue();
+        }
+        
+        if (!escapeXml)
+            value = decode(value);
+        else 
+            value = encode(value);
+        
+        text.setJsfid("outputText");
+        text.setComponentType("javax.faces.HtmlOutputText");
+        
+        // add a value attribute
+        AttributeBean attr = new AttributeBean();
+        attr.setName("value");
+        attr.setValue(value);
+        text.addAttribute(attr);
+        
+        // add a escape attribute
+        attr = new AttributeBean();
+        attr.setName("escape");
+        attr.setValue(Boolean.FALSE.toString());
+        text.addAttribute(attr);
+        
+        // add a isTransient attribute
+        attr = new AttributeBean();
+        attr.setName("isTransient");
+        attr.setValue(Boolean.TRUE.toString());
+        text.addAttribute(attr);
+        
+    }
+
+    /**
+     * <p>This is a method binding "validator" signature that can be bound to 
the 
+     * <code>shapeValidator</code> attribute of the [EMAIL PROTECTED] 
org.apache.shale.clay.component.Clay}
+     * component.  It expects that the <code>url</code> attribute will contain 
the file to import
+     * relative to the web context root. The content of the file will be 
encode or decode depending 
+     * on the value of the <code>escapeXml</code> optional attribute.  The 
default doesn't apply
+     * any encoding. </p>   
+     */
+    public void clayImport(javax.faces.context.FacesContext context,
+            javax.faces.component.UIComponent component,
+            java.lang.Object displayElementRoot) {
+        
+        Tags tagUtils = (Tags) context.getApplication().getVariableResolver()
+                                      .resolveVariable(context, 
ShaleConstants.TAG_UTILITY_BEAN);
+        if (tagUtils == null)
+            throw new 
NullPointerException(messages.getMessage("clay.null.tagUtils"));
+
+        
+        if (!(displayElementRoot instanceof ComponentBean) ||
+                !(component instanceof Clay)) {
+            throw new RuntimeException(messages.getMessage("invalid.binding", 
new Object[] {"clayImport"}));    
+        }
+        
+        ComponentBean text = (ComponentBean) displayElementRoot;
+        Clay clay = (Clay) component;
+        String url = (String) clay.getAttributes().get("url");
+        if (url == null) {
+            throw new 
RuntimeException(messages.getMessage("missing.attribute", new Object[] {"url", 
"clayImport"}));    
+        }
+        url = tagUtils.eval(url);
+        
+        boolean escapeXml = true;
+        String escAttribute = (String) clay.getAttributes().get("escapeXml");
+        if (escAttribute != null) {
+           escapeXml =  tagUtils.evalBoolean(escAttribute).booleanValue();
+        }
+                
+        StringBuffer value = new StringBuffer();
+        
+        InputStream in = null;
+        try {
+            in = context.getExternalContext().getResourceAsStream(url);
+            int c = 0;
+            done: while (true) {
+                c = in.read();
+                if (c > -1)
+                    value.append((char) c);
+                else
+                    break done;
+                
+            }
+        } catch (IOException e) {
+            throw new 
RuntimeException(messages.getMessage("invalid.attribute", new Object[] {"url", 
"clayImport"}));
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {}
+            }   
+            
+        }
+        
+        if (escAttribute != null) {
+           if (!escapeXml)
+               replace(value, decodeMap);
+           else 
+               replace(value, encodeMap);
+        }
+           
+        text.setJsfid("outputText");
+        text.setComponentType("javax.faces.HtmlOutputText");
+        
+        // add a value attribute
+        AttributeBean attr = new AttributeBean();
+        attr.setName("value");
+        attr.setValue(value.toString());
+        text.addAttribute(attr);
+        
+        // add a escape attribute
+        attr = new AttributeBean();
+        attr.setName("escape");
+        attr.setValue(Boolean.FALSE.toString());
+        text.addAttribute(attr);
+        
+        // add a isTransient attribute
+        attr = new AttributeBean();
+        attr.setName("isTransient");
+        attr.setValue(Boolean.TRUE.toString());
+        text.addAttribute(attr);
+    }   
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/ClayAmalgam.java
------------------------------------------------------------------------------
    svn:keywords = date author id rev

Added: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
URL: 
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java?rev=345441&view=auto
==============================================================================
--- 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
 (added)
+++ 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
 Thu Nov 17 20:26:10 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+package org.apache.shale.clay.utils;
+
+import org.apache.commons.chain.CatalogFactory;
+import org.apache.commons.chain.Context;
+import org.apache.commons.chain.generic.LookupCommand;
+
+/**
+ * <p>This chains class performs a check to verify the catalog exists.
+ * If the catalog doesn't exist, it returns <code>true</code> if the
+ * <code>optional</code> property in the super class is <code>true</code>.
+ * If the catalog is not found and the command is not optional, it returns a
+ * <code>false</code> value.  Otherwise, if the catalog exists, the super 
+ * implementation is invoked.</p>
+ *
+ */
+public class PluggableLookupCommand extends LookupCommand {
+
+
+    /**
+     * <p>Checks to see if the catalog exists.</p>
+     */
+    private boolean catalogExists() {
+        String catalogName = getCatalogName();
+        if (catalogName == null) {
+            return false; 
+        }     
+        CatalogFactory catalogFactory = CatalogFactory.getInstance();
+        
+        return (catalogFactory.getCatalog(catalogName) != null);
+    }
+    
+    /**
+     * <p>Adds an additional check to determine if the catalog name is loaded. 
 
+     * If loaded, the super implementation is invoked.  Otherwise, the chain 
+     * continues if the command is optional.</p>
+     */
+    public boolean execute(Context context) throws Exception {
+
+        if (!catalogExists()) {
+           return !isOptional();
+        } 
+        
+        return super.execute(context);
+    }
+
+}

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/utils/PluggableLookupCommand.java
------------------------------------------------------------------------------
    svn:keywords = date author id rev



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

Reply via email to