Author: craigmcc
Date: Fri Apr 29 18:43:57 2005
New Revision: 165370
URL: http://svn.apache.org/viewcvs?rev=165370&view=rev
Log:
Add four new source files included in this patch.
PR: Bugzilla #34496
Submitted By: Gary VanMatre <gvanmatre AT comcast.net>
Added:
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextareaBuilder.java
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/AnchorBuilderRule.java
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/TextareaBuilderRule.java
Added:
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextareaBuilder.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextareaBuilder.java?rev=165370&view=auto
==============================================================================
---
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextareaBuilder.java
(added)
+++
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/InputTextareaBuilder.java
Fri Apr 29 18:43:57 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.parser.builder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.config.Globals;
+import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.parser.Node;
+
+/**
+ * <p>
+ * Builds a [EMAIL PROTECTED] ElementBean} from a HTML [EMAIL PROTECTED] Node}
where the
+ * [EMAIL PROTECTED]
org.apache.shale.clay.parser.builder.chain.TextareaBuilderRule}
+ * handles the mapping
+ * </p>
+ */
+public class InputTextareaBuilder extends Builder {
+
+ /**
+ * <p>
+ * Common logger utility class
+ * </p>
+ */
+ private static Log log;
+ static {
+ log = LogFactory.getLog(InputTextareaBuilder.class);
+ }
+
+ /**
+ * <p>
+ * The default for this builder is that builder will handle the children
+ * html nodes meaning that the default should be <code>true</code>. The
+ * default can be overridden by the "allowBody" attribute in the component
+ * metadata.
+ * </p>
+ */
+ protected boolean getBuildNodeBody(Node node, ElementBean target) {
+ // if override attribute then let the super sort it out
+ if (target != null
+ && target.getAttributes().containsKey(
+ Globals.COMPONENT_ATTRIBUTE_ALLOW_BODY))
+ return super.getBuildNodeBody(node, target);
+ else {
+ // default for this HTML element is to let the node build
+ // the body and not each child's builder
+ return true;
+ }
+ }
+
+ /**
+ * <p>
+ * Returns the <code>jsfid</code> used to populate the [EMAIL PROTECTED]
ElementBean}
+ * </p>
+ */
+ protected String getJsfid(Node node) {
+ return "inputTextarea";
+ }
+
+ /**
+ * <p>
+ * Returns the JSF componentType of
+ * <code>javax.faces.HtmlInputTextarea</code> used to define the
+ * [EMAIL PROTECTED] ElementBean} from the HTML [EMAIL PROTECTED] Node}
+ * </p>
+ */
+ protected String getComponentType(Node node) {
+ return "javax.faces.HtmlInputTextarea";
+ }
+
+}
\ No newline at end of file
Added:
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java?rev=165370&view=auto
==============================================================================
---
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
(added)
+++
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/OutputLinkBuilder.java
Fri Apr 29 18:43:57 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.parser.builder;
+
+/**
+ * <p>
+ * This [EMAIL PROTECTED] Builder} will create a target [EMAIL PROTECTED]
ElementBean} for a "<a>"
+ * [EMAIL PROTECTED] Node}. The mapping between the html and the builder is
handled by the
+ * [EMAIL PROTECTED] AnchorBuilderRule}.
+ * </p>
+ */
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.shale.clay.parser.Node;
+
+public class OutputLinkBuilder extends Builder {
+
+ /**
+ * <p>
+ * Common logger utility class
+ * </p>
+ */
+ private static Log log;
+ static {
+ log = LogFactory.getLog(OutputLinkBuilder.class);
+ }
+
+ /**
+ * <p>
+ * Returns a jsf component type of <code>javax.faces.HtmlOutputLink</code>
+ * </p>
+ */
+ protected String getComponentType(Node node) {
+ return "javax.faces.HtmlOutputLink";
+ }
+
+ /**
+ * <p>
+ * Returns a <code>jsfid</code> that will populate the target
+ * [EMAIL PROTECTED] org.apache.shale.clay.config.beans.ElementBean}
+ * </p>
+ */
+ protected String getJsfid(Node node) {
+ return "outputLink";
+ }
+
+ /**
+ * <p>
+ * Returns <code>true</code> meaning that the target JSF component can
+ * have children
+ * </p>
+ */
+ public boolean isChildrenAllowed() {
+ return true;
+ }
+
+}
Added:
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/AnchorBuilderRule.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/AnchorBuilderRule.java?rev=165370&view=auto
==============================================================================
---
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/AnchorBuilderRule.java
(added)
+++
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/AnchorBuilderRule.java
Fri Apr 29 18:43:57 2005
@@ -0,0 +1,74 @@
+/*
+ * 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.parser.builder.chain;
+
+/**
+ * <p>
+ * This is a <code>Command</code> implementation that will
+ * match a HTML [EMAIL PROTECTED] Node} with a matching [EMAIL PROTECTED]
Builder}
+ * implementation. If the html node is an anchored tag, a
+ * [EMAIL PROTECTED] OutputLinkBuilder} will be returned and the
+ * chain terminated. The [EMAIL PROTECTED] BuilderFactory} runs this
+ * command rule as part of the <code>Globals.BUILDER_CATALOG_NAME</code>
+ * found in the <code>Globals.BUILDER_RESOURCE_NAME</code> and
+ * invoking the <code>Globals.FIND_BUILDER_COMMAND_NAME</code>
+ * </p>
+ */
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.shale.clay.parser.Node;
+import org.apache.shale.clay.parser.builder.Builder;
+import org.apache.shale.clay.parser.builder.OutputLinkBuilder;
+
+/**
+ *
+ *
+ */
+public class AnchorBuilderRule implements Command {
+
+ /**
+ * <p>
+ * Static instance of the builder
+ * </p>
+ */
+ private static final Builder builder = new OutputLinkBuilder();
+
+ /**
+ * <p>
+ * Uses the [EMAIL PROTECTED] BuilderRuleContext} to find the current html
[EMAIL PROTECTED] Node}.
+ * If the node is an anchored element, return an instance if the builder
and
+ * stop the chain.
+ * </p>
+ */
+ public boolean execute(Context context) throws Exception {
+
+ boolean isFinal = false;
+
+ BuilderRuleContext builderRuleContext = (BuilderRuleContext) context;
+ Node node = builderRuleContext.getNode();
+ if (node.getName() != null && node.getName().equalsIgnoreCase("a")) {
+ builderRuleContext.setBuilder(builder);
+ isFinal = true;
+
+ }
+
+ return isFinal;
+ }
+
+}
Added:
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/TextareaBuilderRule.java
URL:
http://svn.apache.org/viewcvs/struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/TextareaBuilderRule.java?rev=165370&view=auto
==============================================================================
---
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/TextareaBuilderRule.java
(added)
+++
struts/shale/trunk/clay-plugin/src/java/org/apache/shale/clay/parser/builder/chain/TextareaBuilderRule.java
Fri Apr 29 18:43:57 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.parser.builder.chain;
+
+/**
+ * <p>
+ * This <code>Command</code> rule will map an html textarea [EMAIL PROTECTED]
Node} to a
+ * [EMAIL PROTECTED] InputTextareaBuilder}.
+ * </p>
+ */
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.shale.clay.parser.Node;
+import org.apache.shale.clay.parser.builder.Builder;
+import org.apache.shale.clay.parser.builder.InputTextareaBuilder;
+
+public class TextareaBuilderRule implements Command {
+
+ /**
+ * <p>
+ * Instance of the target
+ * [EMAIL PROTECTED]
org.apache.shale.clay.parser.builder.InputTextareaBuilder}
+ * </p>
+ */
+ private static final Builder builder = new InputTextareaBuilder();
+
+ /**
+ * <p>
+ * Returns <code>false</code> if the html [EMAIL PROTECTED] Node} was not
a textarea.
+ * The [EMAIL PROTECTED] BuilderRuleContext} will be passed as a
parameter. If a match
+ * is found, a <code>true</code> value is returned completing the chain.
+ * </p>
+ */
+ public boolean execute(Context context) throws Exception {
+
+ boolean isFinal = false;
+
+ BuilderRuleContext builderRuleContext = (BuilderRuleContext) context;
+ Node node = builderRuleContext.getNode();
+ if (node.getName() != null
+ && node.getName().equalsIgnoreCase("textarea")) {
+ builderRuleContext.setBuilder(builder);
+ isFinal = true;
+
+ }
+
+ return isFinal;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]