Author: gvanmatre Date: Thu Oct 27 17:58:52 2005 New Revision: 329014 URL: http://svn.apache.org/viewcvs?rev=329014&view=rev Log: Fix identified by Ryan Wynn for the new Clay symbol replacement and a few other small optimization changes.
Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java?rev=329014&r1=329013&r2=329014&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/Clay.java Thu Oct 27 17:58:52 2005 @@ -39,7 +39,6 @@ import org.apache.shale.clay.component.chain.AbstractCommand; import org.apache.shale.clay.component.chain.ClayContext; import org.apache.shale.clay.config.Globals; -import org.apache.shale.clay.config.beans.AttributeBean; import org.apache.shale.clay.config.beans.ComponentBean; import org.apache.shale.clay.config.beans.ConfigBean; import org.apache.shale.clay.config.beans.ConfigBeanFactory; @@ -283,21 +282,15 @@ // or alter the root display element by // using the getter and setter for the displayElementRoot if (this.getShapeValidator() != null) { - - //Short cut to reuse logic for resolving the literal "managed-bean-name" - AttributeBean attr = new AttributeBean(); - attr.setName("validator"); - attr.setValue(getShapeValidator()); - attr.setBindingType(AttributeBean.BINDING_TYPE_NONE); - + ClayContext clayContext = new ClayContext(); - clayContext.setAttribute(attr); Map symbolTable = new TreeMap(); symbolTable.put(Globals.MANAGED_BEAN_MNEMONIC, getManagedBeanName()); clayContext.setSymbols(symbolTable); - - String expr = AbstractCommand.replaceMnemonic(clayContext); + + //resolve the literal "managed-bean-name" + String expr = AbstractCommand.replaceMnemonic(clayContext, getShapeValidator()); Class[] methodSignature = { javax.faces.context.FacesContext.class, javax.faces.component.UIComponent.class, Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java?rev=329014&r1=329013&r2=329014&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/AbstractCommand.java Thu Oct 27 17:58:52 2005 @@ -75,16 +75,27 @@ return catalog; } - + /** * <p> * This call is used to substitue an attribute binding expression containing * the <code>symbols</code> with the target property value in the [EMAIL PROTECTED] ClayContext}. + * The current attribute within the context is assumed. * </p> */ public static String replaceMnemonic(ClayContext context) { + return replaceMnemonic(context, context.getAttribute().getValue()); + } + + /** + * <p> + * This call is used to substitue an attribute binding expression containing + * the <code>symbols</code> within the <code>sybmolToken</code>. + * </p> + */ + public static String replaceMnemonic(ClayContext context, String symbolToken) { - StringBuffer buff = new StringBuffer(context.getAttribute().getValue()); + StringBuffer buff = new StringBuffer(symbolToken); Map symbols = context.getSymbols(); Iterator si = symbols.entrySet().iterator(); @@ -92,11 +103,10 @@ Map.Entry e = (Map.Entry) si.next(); String key = (String) e.getKey(); String value = (String) e.getValue(); - int i = 0; while (i <= (buff.length() - key.length())) { String token = buff.substring(i, i + key.length()); - if (token.compareToIgnoreCase(key) == 0) { + if (token.equalsIgnoreCase(key)) { buff.delete(i, i + key.length()); buff.insert(i, value); i = i + value.length(); Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java?rev=329014&r1=329013&r2=329014&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/component/chain/CreateComponentCommand.java Thu Oct 27 17:58:52 2005 @@ -77,6 +77,8 @@ String id = null; if ((id = displayElement.getId()) == null) id = facesContext.getViewRoot().createUniqueId(); + else + id = replaceMnemonic(clayContext, id); UIComponent child = null; if (displayElement.getFacetName() != null) @@ -96,7 +98,7 @@ child.setId(id); if (displayElement.getFacetName() != null) { - parent.getFacets().put(displayElement.getFacetName(), child); + parent.getFacets().put(replaceMnemonic(clayContext, displayElement.getFacetName()), child); if (log.isDebugEnabled()) log.debug(messages.getMessage("create.facet.component", Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java?rev=329014&r1=329013&r2=329014&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/config/beans/ComponentConfigBean.java Thu Oct 27 17:58:52 2005 @@ -24,6 +24,7 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -255,7 +256,7 @@ * collection.</p> */ public ComponentConfigBean() { - displayElements = new TreeMap(); + displayElements = new HashMap(1000); } /** @@ -1229,7 +1230,7 @@ //check fo duplicate component id's String id = b.getId(); - if (id != null) { + if (id != null && (id.indexOf('@') == -1)) { if (componentIds.contains(id)) { throw new NullPointerException(messages.getMessage("duplicate.componentid.exception", new Object[] {id, b})); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]