Author: gvanmatre Date: Sun Jan 22 17:16:38 2006 New Revision: 371430 URL: http://svn.apache.org/viewcvs?rev=371430&view=rev Log: Added a new reserved “void” clay directive. Html elements bound with the jsfid of “void” will produce no output. The corresponding Html element will be excluded from the target view but keep a transient placeholder within the component tree.
Added: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VoidBuilder.java struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DirectiveBuilderRule.java - copied, changed from r370010, struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/IgnoreBuilderRule.java Removed: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/IgnoreBuilderRule.java Modified: struts/shale/trunk/clay-plugin/src/conf/clay-config.xml struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml Modified: struts/shale/trunk/clay-plugin/src/conf/clay-config.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/conf/clay-config.xml?rev=371430&r1=371429&r2=371430&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/conf/clay-config.xml (original) +++ struts/shale/trunk/clay-plugin/src/conf/clay-config.xml Sun Jan 22 17:16:38 2006 @@ -194,6 +194,12 @@ <!-- acts like a comment tag treating child nodes as verbatim --> <component jsfid="ignore" componentType="javax.faces.HtmlOutputText" /> + <!-- creates an empty node --> + <component jsfid="void" componentType="javax.faces.HtmlOutputText"> + <attributes> + <set name="isTransient" bindingType="VB" value="true" /> + </attributes> + </component> <!-- Added: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VoidBuilder.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VoidBuilder.java?rev=371430&view=auto ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VoidBuilder.java (added) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/VoidBuilder.java Sun Jan 22 17:16:38 2006 @@ -0,0 +1,66 @@ +/* + * 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: VerbatimBuilder.java 359115 2005-12-26 22:44:06Z wsmoak $ + */ + +package org.apache.shale.clay.parser.builder; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.shale.clay.config.beans.AttributeBean; +import org.apache.shale.clay.config.beans.ComponentBean; +import org.apache.shale.clay.config.beans.ElementBean; +import org.apache.shale.clay.parser.Node; + + +/** + * <p> + * This is a [EMAIL PROTECTED] Builder} that will create a void [EMAIL PROTECTED] ElementBean}. + * The element bean will be an empty placeholder. The HTML element will + * contain nothing.</p> + */ +public class VoidBuilder extends Builder { + + /** + * <p> + * Common logger utility class. + * </p> + */ + private static Log log; + static { + log = LogFactory.getLog(VoidBuilder.class); + } + + /** + * <p> + * Returns the <code>jsfid</code> for the target [EMAIL PROTECTED] ElementBean}. + * </p> + */ + protected String getJsfid(Node node) { + return "void"; + } + + /** + * <p> + * Returns a JSF component type of <code>javax.faces.HtmlOutputText</code>. + * </p> + */ + protected String getComponentType(Node node) { + return "javax.faces.HtmlOutputText"; + } + + +} Copied: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DirectiveBuilderRule.java (from r370010, struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/IgnoreBuilderRule.java) URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DirectiveBuilderRule.java?p2=struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DirectiveBuilderRule.java&p1=struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/IgnoreBuilderRule.java&r1=370010&r2=371430&rev=371430&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/IgnoreBuilderRule.java (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/DirectiveBuilderRule.java Sun Jan 22 17:16:38 2006 @@ -23,27 +23,29 @@ import org.apache.shale.clay.parser.Node; import org.apache.shale.clay.parser.builder.Builder; import org.apache.shale.clay.parser.builder.IgnoreBuilder; +import org.apache.shale.clay.parser.builder.VoidBuilder; /** * <p>This builder will be ordered first in the rule registration list. * If the node has a <code>jsfid</code> attribute, and its value is - * "ignore", child elements will be rendered as comment/verbatim - * content.</p> + * "ignore", or "void" then special assumptions will be made.</p> */ -public class IgnoreBuilderRule implements Command { +public class DirectiveBuilderRule implements Command { /** - * <p>The builder that will ignore a block similar to the - * CommentBuilder. + * <p>The builders that will assined to a "ignore" or "void" + * [EMAIL PROTECTED] Builder}. * <p> */ - private static final Builder[] builders = {new IgnoreBuilder()}; + private static final Builder[] builders = {new IgnoreBuilder(), new VoidBuilder()}; /** * <p>If the node has a <code>jsfid</code> attribute, and its value is * "ignore", child elements will be rendered as comment/verbatim * content. The enclosing tag will not be rendered in the document, - * only it's children.</p> + * only it's children. If the <code>jsfid</code> is "void", + * the element will not be rendered but its children will + * keep their original characteristics.</p> */ public boolean execute(Context context) throws Exception { boolean isFinal = false; @@ -56,6 +58,9 @@ if (jsfid.equals("ignore")) { builderRuleContext.setBuilder(builders[0]); isFinal = true; + } else if (jsfid.equals("void")) { + builderRuleContext.setBuilder(builders[1]); + isFinal = true; } } } Modified: struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml?rev=371430&r1=371429&r2=371430&view=diff ============================================================================== --- struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml (original) +++ struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/shale-builder-config.xml Sun Jan 22 17:16:38 2006 @@ -24,7 +24,7 @@ <chain name="findBuilder"> - <command className="org.apache.shale.clay.parser.builder.chain.IgnoreBuilderRule"/> + <command className="org.apache.shale.clay.parser.builder.chain.DirectiveBuilderRule"/> <command className="org.apache.shale.clay.parser.builder.chain.InputBuilderRule"/> <command className="org.apache.shale.clay.parser.builder.chain.FormBuilderRule"/> <command className="org.apache.shale.clay.parser.builder.chain.SelectBuilderRule"/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]