Author: gvanmatre
Date: Sun Jan 21 08:33:30 2007
New Revision: 498396
URL: http://svn.apache.org/viewvc?view=rev&rev=498396
Log:
In preparation for cloning the shale-clay-starter-archetype (contributed by
Hermod Opstvedt) to seed a shale-clay-trinidad-archetype, I've expanded the
generated trinidad clay config to include the custom trinidad action listeners,
converters and validators. I also added a simple example of using the trinidad
"pageFlowScope".
Added:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java
(with props)
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java
(with props)
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java
(with props)
shale/sandbox/shale-clay-trinidad/src/main/resources/META-INF/tr-incubator-m1-SNAPSHOT-config.xml
(with props)
shale/sandbox/shale-clay-trinidad/src/main/resources/META-INF/trh-incubator-m1-SNAPSHOT-config.xml
(with props)
Modified:
shale/sandbox/shale-clay-trinidad/pom.xml
shale/sandbox/shale-clay-trinidad/src/main/webapp/WEB-INF/chain-config.xml
shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/index.html
shale/sandbox/shale-clay-trinidad/src/main/webapp/pages/page2.html
Modified: shale/sandbox/shale-clay-trinidad/pom.xml
URL:
http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/pom.xml?view=diff&rev=498396&r1=498395&r2=498396
==============================================================================
--- shale/sandbox/shale-clay-trinidad/pom.xml (original)
+++ shale/sandbox/shale-clay-trinidad/pom.xml Sun Jan 21 08:33:30 2007
@@ -15,7 +15,7 @@
<finalName>${artifactId}</finalName>
<plugins>
-
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -24,7 +24,8 @@
<target>1.5</target>
</configuration>
</plugin>
-
+
+ <!--
<plugin>
<groupId>org.apache.shale</groupId>
<artifactId>Tld2ClayCfgMojo</artifactId>
@@ -57,7 +58,7 @@
</tlds>
</configuration>
</plugin>
-
+ -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
@@ -185,37 +186,37 @@
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-application</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-clay</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-core</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-view</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-tiger</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.shale</groupId>
<artifactId>shale-test</artifactId>
- <version>1.0.4-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
Added:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java?view=auto&rev=498396
==============================================================================
---
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java
(added)
+++
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java
Sun Jan 21 08:33:30 2007
@@ -0,0 +1,117 @@
+package org.apache.shale.clay.component.chain.trinidad;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionListener;
+
+import org.apache.commons.chain.Context;
+import
org.apache.myfaces.trinidadinternal.taglib.listener.ReturnActionListener;
+import org.apache.myfaces.trinidadinternal.taglib.listener.SetActionListener;
+import org.apache.shale.clay.component.chain.ClayContext;
+import org.apache.shale.clay.config.beans.AttributeBean;
+import org.apache.shale.clay.config.beans.ComponentBean;
+
+/**
+ * <p>This is a "preprocessAddActionListener" Command registered in the
"clayCustomization"
+ * catalog. This command will be invoked before the default handler. If the
+ * action lister is a custom trinidad listener, setActionListener or
returnActionListener,
+ * custom logic will add the target listener to the parent ActionSource
component.
+ * These two listeners have ValueBinding instead of simple properties.</p>
+ */
+public class CreateActionListenerCommand extends
+ org.apache.shale.clay.component.chain.CreateActionListenerCommand {
+
+ /**
+ * <p>Fully qualified classname of the setActionListener.</p>
+ */
+ private static final String SETACTIONLISTENER =
"org.apache.myfaces.trinidadinternal.taglib.listener.SetActionListener";
+
+ /**
+ * <p>Fully qualified classname of the returnActionListener.</p>
+ */
+ private static final String RETURNACTIONLISTENER =
"org.apache.myfaces.trinidadinternal.taglib.listener.ReturnActionListener";
+
+ /**
+ * @param context faces context
+ * @param attr clay config bean holding information about a listeners
property
+ * @return <code>ValueBinding</code> for the target <code>attr</code>
+ */
+ private ValueBinding getProperty(FacesContext context, AttributeBean attr)
{
+ if (attr == null) {
+ return null;
+ }
+
+ if (attr.getValue() == null || !isValueReference(attr.getValue())) {
+ return null;
+ }
+
+ ValueBinding vb = context.getApplication().createValueBinding(
+ attr.getValue());
+ return vb;
+ }
+
+ /**
+ * <p>Intercepts the Listener that is about to be created for the config
bean.
+ * If the componentType (classname) matches the setActionListener or
returnActionListener
+ * componentType's, this command handles adding it to the parent.
Otherwise,
+ * the default method for handling actionListeners is invoked.</p>
+ *
+ * @param context commons chains context
+ * @return <code>true</code> if the target listener is a setActionLister
or returnActionListener
+ */
+ public boolean execute(Context context) throws Exception {
+
+ ClayContext clayContext = (ClayContext) context;
+ if (clayContext == null) {
+ throw new NullPointerException(getMessages().getMessage(
+ "clay.null.clayContext"));
+ }
+
+ ComponentBean displayElement = clayContext.getDisplayElement();
+ if (displayElement == null) {
+ throw new NullPointerException(getMessages().getMessage(
+ "clay.null.componentBean"));
+ }
+
+ // is this a special action listener
+ String componentType = displayElement.getComponentType();
+ if (!componentType.equals(SETACTIONLISTENER)
+ && !componentType.equals(RETURNACTIONLISTENER)) {
+
+ // not a statefull trinidad listener, continue
+ return false;
+ }
+
+ super.execute(context);
+
+ FacesContext facesContext = clayContext.getFacesContext();
+ if (facesContext == null) {
+ throw new NullPointerException(getMessages().getMessage(
+ "clay.null.facesContext"));
+ }
+
+ ActionListener listener = (ActionListener) clayContext.getChild();
+ if (listener instanceof SetActionListener) {
+ AttributeBean toAttr = displayElement.getAttribute("to");
+ AttributeBean fromAttr = displayElement.getAttribute("from");
+
+ ((SetActionListener) listener)
+ .setValueBinding(SetActionListener.TO_KEY, getProperty(
+ facesContext, toAttr));
+ ((SetActionListener) listener).setValueBinding(
+ SetActionListener.FROM_KEY, getProperty(facesContext,
+ fromAttr));
+
+ } else if (listener instanceof ReturnActionListener) {
+ AttributeBean valueAttr = displayElement.getAttribute("value");
+ ((ReturnActionListener) listener).setValueBinding(
+ ReturnActionListener.VALUE_KEY, getProperty(facesContext,
+ valueAttr));
+ }
+
+ // stop parent chain
+ return true;
+
+ }
+
+}
Propchange:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/component/chain/trinidad/CreateActionListenerCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java?view=auto&rev=498396
==============================================================================
---
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java
(added)
+++
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java
Sun Jan 21 08:33:30 2007
@@ -0,0 +1,80 @@
+package org.apache.shale.clay.parser.builder.trinidad;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.shale.clay.config.beans.ComponentBean;
+import org.apache.shale.clay.config.beans.ElementBean;
+import org.apache.shale.clay.parser.Node;
+import org.apache.shale.clay.parser.builder.JsfDefaultBuilder;
+
+/**
+ * <p>Handles mapping the custom trinidad actionListeners in addition to
+ * the stardard mapping rules.</p>
+ */
+public class JsfTrinidadBuilder extends JsfDefaultBuilder {
+
+ /**
+ * <p>Build's a <code>target</code> [EMAIL PROTECTED] ElementBean} from a
[EMAIL PROTECTED] Node}. The
+ * following child nodes are handles outside of the
<code>encodeChildren</code>
+ * method: symbol, facet, attribute, convert, validate, actionListener,
+ * and valueChangeListener.
+ * </p>
+ *
+ * @param node markup
+ * @param target child config bean
+ * @param root parent config bean
+ */
+ protected void encodeBegin(Node node, ElementBean target, ComponentBean
root) {
+ assignNode(node, target);
+
+ List deleteList = new ArrayList();
+ Iterator ci = node.getChildren().iterator();
+ next: while (ci.hasNext()) {
+ Node child = (Node) ci.next();
+ if (child.isWellFormed() && child.getName() != null) {
+ if (child.getName().equals("symbol")) {
+ addSymbol(child, target);
+ deleteList.add(child);
+ } else if (child.getName().equals("facet")) {
+ addFacet(child, target);
+ deleteList.add(child);
+ } else if (child.getName().equals("attribute")) {
+ addAttribute(child, target);
+ deleteList.add(child);
+ } else if (child.getName().startsWith("convert")) {
+ addConverter(child, target);
+ deleteList.add(child);
+ } else if (child.getName().startsWith("validate")
+ || child.getName().startsWith("validator")
+ || child.getName().startsWith("commonsValidator")) {
+ addValidator(child, target);
+ deleteList.add(child);
+ } else if (child.getName().equals("actionListener")
+ || child.getName().endsWith("ActionListener")) {
+ addActionListener(child, target);
+ deleteList.add(child);
+ } else if (child.getName().equals("valueChangeListener")) {
+ addValueChangeListener(child, target);
+ deleteList.add(child);
+ }
+ } else {
+ if (node.getName() != null &&
node.getName().equals("verbatim")) {
+ continue next;
+ }
+ if (child.isComment() || isNodeWhitespace(child)) {
+ // remove white space
+ deleteList.add(child);
+ }
+ }
+ }
+
+ ci = deleteList.iterator();
+ while (ci.hasNext()) {
+ node.getChildren().remove(ci.next());
+ }
+
+ }
+
+}
Propchange:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/JsfTrinidadBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java
URL:
http://svn.apache.org/viewvc/shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java?view=auto&rev=498396
==============================================================================
---
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java
(added)
+++
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java
Sun Jan 21 08:33:30 2007
@@ -0,0 +1,31 @@
+package org.apache.shale.clay.parser.builder.trinidad.chain;
+
+import org.apache.commons.chain.Context;
+import org.apache.shale.clay.parser.builder.Builder;
+import org.apache.shale.clay.parser.builder.chain.BuilderRuleContext;
+import org.apache.shale.clay.parser.builder.chain.JsfDefaultBuilderRule;
+import org.apache.shale.clay.parser.builder.trinidad.JsfTrinidadBuilder;
+
+public class JsfTrinidadBuilderRule extends JsfDefaultBuilderRule {
+
+ /**
+ * <p>Generic [EMAIL PROTECTED] Builder} that handles JSP style of
markup's.</p>
+ */
+ private final JsfTrinidadBuilder builder = new JsfTrinidadBuilder();
+
+ /**
+ * <p>Assigns handling of the markup to [EMAIL PROTECTED]
org.apache.shale.clay.parser.builder.trinidad.JsfTrinidadBuilder}
+ * without condition.</p>
+ *
+ * @param context common chains
+ * @return <code>true</code> if the chain is done
+ */
+ public boolean execute(Context context) {
+
+ BuilderRuleContext builderRuleContext = (BuilderRuleContext) context;
+ builderRuleContext.setBuilder(builder);
+
+ return true;
+ }
+
+}
Propchange:
shale/sandbox/shale-clay-trinidad/src/main/java/org/apache/shale/clay/parser/builder/trinidad/chain/JsfTrinidadBuilderRule.java
------------------------------------------------------------------------------
svn:eol-style = native