You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by cn...@apache.org on 2016/02/03 10:53:36 UTC
[01/13] struts git commit: fixed tiles showcase by setting dtd to 3.0
Repository: struts
Updated Branches:
refs/heads/master 954a29efc -> 6d2a57355
fixed tiles showcase by setting dtd to 3.0
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d9f4054b
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d9f4054b
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d9f4054b
Branch: refs/heads/master
Commit: d9f4054b1367cd7ab6e3f22b9cc677f62def4e83
Parents: 249d2f8
Author: cnenning <cn...@apache.org>
Authored: Fri Jan 22 14:59:48 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Fri Jan 22 14:59:48 2016 +0100
----------------------------------------------------------------------
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 96 ++++++++++----------
1 file changed, 48 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d9f4054b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index 7c7057f..027f9a4 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -1,48 +1,48 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!--
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- *
- */
--->
-
-<!DOCTYPE tiles-definitions PUBLIC
- "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
- "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
-
-<tiles-definitions>
-
- <definition name="showcase.index" template="/WEB-INF/tiles/layout.jsp">
- <put-attribute name="title" value="Tiles Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/>
- </definition>
-
- <definition name="showcase.freemarker" template="/WEB-INF/tiles/layout.jsp">
- <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
- </definition>
-
- <definition name="showcase.freemarkerLayout" template="/WEB-INF/tiles/layout.ftl">
- <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
- </definition>
-
-</tiles-definitions>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+-->
+
+<!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
+ "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
+
+<tiles-definitions>
+
+ <definition name="showcase.index" template="/WEB-INF/tiles/layout.jsp">
+ <put-attribute name="title" value="Tiles Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/>
+ </definition>
+
+ <definition name="showcase.freemarker" template="/WEB-INF/tiles/layout.jsp">
+ <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
+ </definition>
+
+ <definition name="showcase.freemarkerLayout" template="/WEB-INF/tiles/layout.ftl">
+ <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
+ </definition>
+
+</tiles-definitions>
[12/13] struts git commit: WW-4594 Merges #85 which adds annotations
to configure tiles
Posted by cn...@apache.org.
WW-4594 Merges #85 which adds annotations to configure tiles
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/15688132
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/15688132
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/15688132
Branch: refs/heads/master
Commit: 15688132eff8a5f718ac24794822133fb3fe2d35
Parents: 94691e0 f5ef143
Author: cnenning <cn...@apache.org>
Authored: Wed Feb 3 10:51:15 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Wed Feb 3 10:51:15 2016 +0100
----------------------------------------------------------------------
.../showcase/tiles/TilesAnnotationsAction.java | 40 +++++
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 10 +-
.../src/main/webapp/WEB-INF/tiles/body.jsp | 3 +
.../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 ++
.../tiles/StrutsTilesAnnotationProcessor.java | 177 +++++++++++++++++++
.../tiles/annotation/TilesAddAttribute.java | 30 ++++
.../tiles/annotation/TilesAddListAttribute.java | 28 +++
.../tiles/annotation/TilesDefinition.java | 66 +++++++
.../tiles/annotation/TilesDefinitions.java | 36 ++++
.../tiles/annotation/TilesPutAttribute.java | 32 ++++
.../tiles/annotation/TilesPutListAttribute.java | 32 ++++
.../apache/struts2/views/tiles/TilesResult.java | 69 ++++++--
.../StrutsTilesAnnotationProcessorTest.java | 147 +++++++++++++++
.../TilesTestActionMultipleAnnotations.java | 12 ++
.../tiles/TilesTestActionSingleAnnotation.java | 49 +++++
...TilesTestActionSingleAnnotationAllEmpty.java | 28 +++
16 files changed, 760 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
[13/13] struts git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/struts
Posted by cn...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/struts
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/6d2a5735
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/6d2a5735
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/6d2a5735
Branch: refs/heads/master
Commit: 6d2a57355eb596ddafacc7079b017c4d67d1d9f4
Parents: 1568813 954a29e
Author: cnenning <cn...@apache.org>
Authored: Wed Feb 3 10:51:53 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Wed Feb 3 10:51:53 2016 +0100
----------------------------------------------------------------------
.../xwork2/config/entities/AllowedMethods.java | 3 +
.../xwork2/config/impl/ActionConfigMatcher.java | 1 +
.../interceptor/MessageStoreInterceptor.java | 39 ++++---
.../config/entities/AllowedMethodsTest.java | 15 +++
.../config/impl/ActionConfigMatcherTest.java | 16 ++-
.../MessageStoreInterceptorTest.java | 116 ++++++++++++++++++-
6 files changed, 169 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
[05/13] struts git commit: updated javadoc
Posted by cn...@apache.org.
updated javadoc
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/a53deac7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/a53deac7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/a53deac7
Branch: refs/heads/master
Commit: a53deac7ce8732053edd43dddac329448055aef0
Parents: d76357f
Author: cnenning <cn...@apache.org>
Authored: Mon Jan 25 13:39:47 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Jan 25 13:39:47 2016 +0100
----------------------------------------------------------------------
.../tiles/annotation/TilesDefinition.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/a53deac7/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index a71bbc3..1618b63 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -27,6 +27,26 @@ import java.lang.annotation.Target;
/**
* Represents a <code><definition></code> element in <code>tiles.xml</code>.
*
+ * <p>
+ * With a sample layout in <code>tiles.xml</code> like this:
+ * <pre>
+ * <definition name="layout" template="/WEB-INF/tiles/layout.jsp">
+ * <put-attribute name="header" value=".header"/>
+ * <put-attribute name="body" value=".body"/>
+ * </definition>
+ * </pre>
+ * </p>
+ * <p>
+ * You can annotate an action like that:
+ * <pre>
+ * @Result(name = "success", type="tiles")
+ * @TilesDefinition(extend = "layout", putAttributes = {
+ * @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
+ * @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), })
+ * public class FooAction extends ActionSupport {
+ * </pre>
+ * </p>
+ *
*/
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = { ElementType.TYPE })
[04/13] struts git commit: added tests for
StrutsTilesAnnotationProcessor
Posted by cn...@apache.org.
added tests for StrutsTilesAnnotationProcessor
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d76357fd
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d76357fd
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d76357fd
Branch: refs/heads/master
Commit: d76357fd829a3ea8ddca21d625c49b606cca88d5
Parents: e50c37c
Author: cnenning <cn...@apache.org>
Authored: Mon Jan 25 11:23:10 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Jan 25 11:23:10 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsTilesAnnotationProcessor.java | 7 +-
.../TestStrutsTilesAnnotationProcessor.java | 148 +++++++++++++++++++
.../TilesTestActionMultipleAnnotations.java | 12 ++
.../tiles/TilesTestActionSingleAnnotation.java | 49 ++++++
...TilesTestActionSingleAnnotationAllEmpty.java | 28 ++++
5 files changed, 241 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
index 2ae3ba4..fa5f735 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -66,9 +66,10 @@ public class StrutsTilesAnnotationProcessor {
break;
}
}
- }
- if (tilesDefinitions.value().length > 0) {
- tilesDefinition = tilesDefinitions.value()[0];
+ } else {
+ if (tilesDefinitions.value().length > 0) {
+ tilesDefinition = tilesDefinitions.value()[0];
+ }
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
new file mode 100644
index 0000000..db808cd
--- /dev/null
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class TestStrutsTilesAnnotationProcessor {
+
+ @Test
+ public void findAnnotationSingleAction() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("definition-name", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNameNull() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), null);
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("def1", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNameGiven() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def2");
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("def2", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNotFound() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def3");
+ Assert.assertNull(tilesDefinition);
+ }
+
+ @Test
+ public void buildDefiniton() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+
+ Definition definition = annotationProcessor.buildTilesDefinition("tileName", tilesDefinition);
+
+ Assert.assertNotNull(definition);
+ Assert.assertEquals("tileName", definition.getName());
+ Assert.assertEquals("preparer", definition.getPreparer());
+ Assert.assertEquals("base-definition", definition.getExtends());
+ Attribute templateAttribute = definition.getTemplateAttribute();
+ Assert.assertEquals("template", templateAttribute.getValue());
+ Assert.assertEquals("type", templateAttribute.getRenderer());
+ Assert.assertEquals("role", templateAttribute.getRole());
+ Expression definitionExpressionObject = templateAttribute.getExpressionObject();
+ Assert.assertEquals("templ*", definitionExpressionObject.getExpression());
+ Assert.assertNull(definitionExpressionObject.getLanguage());
+
+ Attribute putAttribute = definition.getAttribute("put-attr");
+ Assert.assertNotNull(putAttribute);
+ Assert.assertEquals("attr-val", putAttribute.getValue());
+ Assert.assertEquals("attr-type", putAttribute.getRenderer());
+ Assert.assertEquals("attr-role", putAttribute.getRole());
+ Expression putAttrExpressionObject = putAttribute.getExpressionObject();
+ Assert.assertEquals("expr", putAttrExpressionObject.getExpression());
+ Assert.assertEquals("lang", putAttrExpressionObject.getLanguage());
+
+ Attribute listAttribute = definition.getAttribute("list-name");
+ Assert.assertEquals("list-role", listAttribute.getRole());
+ List<Attribute> listValue = getListValue(listAttribute);
+ Assert.assertEquals(2, listValue.size());
+
+ Attribute addAttribute = listValue.get(0);
+ Assert.assertEquals("list-attr-role", addAttribute.getRole());
+ Assert.assertEquals("list-attr-val", addAttribute.getValue());
+ Assert.assertEquals("list-attr-type", addAttribute.getRenderer());
+ Expression addAttrExpressionObject = addAttribute.getExpressionObject();
+ Assert.assertEquals("list-attr-expr", addAttrExpressionObject.getExpression());
+
+ Attribute addListAttribute = listValue.get(1);
+ Assert.assertEquals("list-list-attr-role", addListAttribute.getRole());
+ List<Attribute> addListValue = getListValue(addListAttribute);
+ Assert.assertEquals(1, addListValue.size());
+ Assert.assertEquals("list-list-add-attr", addListValue.get(0).getValue());
+
+ Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
+ Assert.assertEquals(2, cascadedAttributeNames.size());
+ Assert.assertTrue(cascadedAttributeNames.contains("put-attr"));
+ Assert.assertTrue(cascadedAttributeNames.contains("list-name"));
+ }
+
+ @Test
+ public void buildDefinitonAllEmpty() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotationAllEmpty(), null);
+
+ Definition definition = annotationProcessor.buildTilesDefinition(null, tilesDefinition);
+
+ Assert.assertNotNull(definition);
+ Assert.assertNull(definition.getName());
+ Assert.assertNull(definition.getPreparer());
+ Assert.assertNull(definition.getExtends());
+ Attribute templateAttribute = definition.getTemplateAttribute();
+ Assert.assertNull(templateAttribute.getValue());
+ //Assert.assertNull(templateAttribute.getRenderer());
+ Assert.assertNull(templateAttribute.getRole());
+ Assert.assertNull(templateAttribute.getExpressionObject());
+
+ Attribute putAttribute = definition.getAttribute("put-attr");
+ Assert.assertNotNull(putAttribute);
+ Assert.assertNull(putAttribute.getValue());
+ Assert.assertNull(putAttribute.getRenderer());
+ Assert.assertNull(putAttribute.getRole());
+ Assert.assertNull(putAttribute.getExpressionObject());
+
+ Attribute listAttribute = definition.getAttribute("list-name");
+ Assert.assertNull(listAttribute.getRole());
+ List<Attribute> listValue = getListValue(listAttribute);
+ Assert.assertEquals(2, listValue.size());
+
+ Attribute addAttribute = listValue.get(0);
+ Assert.assertNull(addAttribute.getRole());
+ Assert.assertNull(addAttribute.getValue());
+ Assert.assertNull(addAttribute.getRenderer());
+ Assert.assertNull(addAttribute.getExpressionObject());
+
+ Attribute addListAttribute = listValue.get(1);
+ Assert.assertNull(addListAttribute.getRole());
+ List<Attribute> addListValue = getListValue(addListAttribute);
+ Assert.assertEquals(1, addListValue.size());
+ Assert.assertNull(addListValue.get(0).getValue());
+
+ Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
+ Assert.assertNull(cascadedAttributeNames);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List<Attribute> getListValue(Attribute listAttribute) {
+ return (List<Attribute>) listAttribute.getValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionMultipleAnnotations.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionMultipleAnnotations.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionMultipleAnnotations.java
new file mode 100644
index 0000000..99a736b
--- /dev/null
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionMultipleAnnotations.java
@@ -0,0 +1,12 @@
+package org.apache.struts2.tiles;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesDefinitions;
+
+@TilesDefinitions({
+ @TilesDefinition(name="def1"),
+ @TilesDefinition(name="def2"),
+})
+public class TilesTestActionMultipleAnnotations {
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotation.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotation.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotation.java
new file mode 100644
index 0000000..c7a98eb
--- /dev/null
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotation.java
@@ -0,0 +1,49 @@
+package org.apache.struts2.tiles;
+
+import org.apache.struts2.tiles.annotation.TilesAddAttribute;
+import org.apache.struts2.tiles.annotation.TilesAddListAttribute;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
+
+@TilesDefinition(
+ name = "definition-name",
+ extend = "base-definition",
+ preparer = "preparer",
+ role = "role",
+ template = "template",
+ templateExpression = "templ*",
+ templateType = "type",
+ putAttributes = {
+ @TilesPutAttribute(
+ cascade = true,
+ expression = "lang:expr",
+ name = "put-attr",
+ role = "attr-role",
+ type = "attr-type",
+ value = "attr-val")
+ },
+ putListAttributes = {
+ @TilesPutListAttribute(
+ cascade = true,
+ inherit = true,
+ name = "list-name",
+ role = "list-role",
+ addAttributes = {
+ @TilesAddAttribute(
+ expression = "list-attr-expr",
+ role = "list-attr-role",
+ type = "list-attr-type",
+ value = "list-attr-val")
+ },
+ addListAttributes = {
+ @TilesAddListAttribute(
+ role = "list-list-attr-role",
+ addAttributes = {@TilesAddAttribute("list-list-add-attr")})
+ }
+ )
+ }
+)
+public class TilesTestActionSingleAnnotation {
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/d76357fd/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotationAllEmpty.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotationAllEmpty.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotationAllEmpty.java
new file mode 100644
index 0000000..4a9aff9
--- /dev/null
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TilesTestActionSingleAnnotationAllEmpty.java
@@ -0,0 +1,28 @@
+package org.apache.struts2.tiles;
+
+import org.apache.struts2.tiles.annotation.TilesAddAttribute;
+import org.apache.struts2.tiles.annotation.TilesAddListAttribute;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
+
+@TilesDefinition(
+ putAttributes = {
+ @TilesPutAttribute(name = "put-attr")
+ },
+ putListAttributes = {
+ @TilesPutListAttribute(
+ name = "list-name",
+ addAttributes = {
+ @TilesAddAttribute()
+ },
+ addListAttributes = {
+ @TilesAddListAttribute(
+ addAttributes = {@TilesAddAttribute()})
+ }
+ )
+ }
+)
+public class TilesTestActionSingleAnnotationAllEmpty {
+
+}
[10/13] struts git commit: turned comments into LOG.trace()
Posted by cn...@apache.org.
turned comments into LOG.trace()
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8651545a
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8651545a
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8651545a
Branch: refs/heads/master
Commit: 8651545aaa34dad22c16969f5697cb5b1055f591
Parents: 9230270
Author: cnenning <cn...@apache.org>
Authored: Mon Feb 1 09:44:22 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Feb 1 09:44:22 2016 +0100
----------------------------------------------------------------------
.../main/java/org/apache/struts2/views/tiles/TilesResult.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/8651545a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index 4656f91..ecbdcee 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -115,7 +115,7 @@ public class TilesResult extends ServletDispatcherResult {
String actionName = invocation.getInvocationContext().getName();
if (StringUtils.isEmpty(location)) {
- // location not set -> action must have one @TilesDefinition
+ LOG.trace("location not set -> action must have one @TilesDefinition");
tilesDefinition = annotationProcessor.findAnnotation(action, null);
String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? tilesDefinition.name() : actionName;
location = tileName;
@@ -142,7 +142,7 @@ public class TilesResult extends ServletDispatcherResult {
}
if (!definitionValid) {
if (tilesDefinition == null) {
- // tilesDefinition not found yet, search in action
+ LOG.trace("tilesDefinition not found yet, searching in action");
tilesDefinition = annotationProcessor.findAnnotation(action, location);
}
if (tilesDefinition != null) {
[09/13] struts git commit: added missing license header
Posted by cn...@apache.org.
added missing license header
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/92302703
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/92302703
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/92302703
Branch: refs/heads/master
Commit: 92302703f2430ee6077fa93f0eabd6dbfc497d9a
Parents: edf7c09
Author: cnenning <cn...@apache.org>
Authored: Mon Feb 1 09:37:25 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Feb 1 09:37:25 2016 +0100
----------------------------------------------------------------------
.../showcase/tiles/TilesAnnotationsAction.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/92302703/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index b5c62f0..2b789c2 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
package org.apache.struts2.showcase.tiles;
import org.apache.struts2.convention.annotation.Namespace;
[07/13] struts git commit: renamed test class to stick to naming
convention
Posted by cn...@apache.org.
renamed test class to stick to naming convention
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9ca6eb98
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9ca6eb98
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9ca6eb98
Branch: refs/heads/master
Commit: 9ca6eb9813ae65a6dd245071825fb9abf63a2a94
Parents: b1588dd
Author: cnenning <cn...@apache.org>
Authored: Mon Jan 25 14:36:07 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Jan 25 14:36:07 2016 +0100
----------------------------------------------------------------------
.../StrutsTilesAnnotationProcessorTest.java | 148 +++++++++++++++++++
.../TestStrutsTilesAnnotationProcessor.java | 148 -------------------
2 files changed, 148 insertions(+), 148 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9ca6eb98/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
new file mode 100644
index 0000000..acaacce
--- /dev/null
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -0,0 +1,148 @@
+package org.apache.struts2.tiles;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.junit.Test;
+
+import org.junit.Assert;
+
+public class StrutsTilesAnnotationProcessorTest {
+
+ @Test
+ public void findAnnotationSingleAction() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("definition-name", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNameNull() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), null);
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("def1", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNameGiven() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def2");
+ Assert.assertNotNull(tilesDefinition);
+ Assert.assertEquals("def2", tilesDefinition.name());
+ }
+
+ @Test
+ public void findAnnotationMultipleActionNotFound() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def3");
+ Assert.assertNull(tilesDefinition);
+ }
+
+ @Test
+ public void buildDefiniton() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
+
+ Definition definition = annotationProcessor.buildTilesDefinition("tileName", tilesDefinition);
+
+ Assert.assertNotNull(definition);
+ Assert.assertEquals("tileName", definition.getName());
+ Assert.assertEquals("preparer", definition.getPreparer());
+ Assert.assertEquals("base-definition", definition.getExtends());
+ Attribute templateAttribute = definition.getTemplateAttribute();
+ Assert.assertEquals("template", templateAttribute.getValue());
+ Assert.assertEquals("type", templateAttribute.getRenderer());
+ Assert.assertEquals("role", templateAttribute.getRole());
+ Expression definitionExpressionObject = templateAttribute.getExpressionObject();
+ Assert.assertEquals("templ*", definitionExpressionObject.getExpression());
+ Assert.assertNull(definitionExpressionObject.getLanguage());
+
+ Attribute putAttribute = definition.getAttribute("put-attr");
+ Assert.assertNotNull(putAttribute);
+ Assert.assertEquals("attr-val", putAttribute.getValue());
+ Assert.assertEquals("attr-type", putAttribute.getRenderer());
+ Assert.assertEquals("attr-role", putAttribute.getRole());
+ Expression putAttrExpressionObject = putAttribute.getExpressionObject();
+ Assert.assertEquals("expr", putAttrExpressionObject.getExpression());
+ Assert.assertEquals("lang", putAttrExpressionObject.getLanguage());
+
+ Attribute listAttribute = definition.getAttribute("list-name");
+ Assert.assertEquals("list-role", listAttribute.getRole());
+ List<Attribute> listValue = getListValue(listAttribute);
+ Assert.assertEquals(2, listValue.size());
+
+ Attribute addAttribute = listValue.get(0);
+ Assert.assertEquals("list-attr-role", addAttribute.getRole());
+ Assert.assertEquals("list-attr-val", addAttribute.getValue());
+ Assert.assertEquals("list-attr-type", addAttribute.getRenderer());
+ Expression addAttrExpressionObject = addAttribute.getExpressionObject();
+ Assert.assertEquals("list-attr-expr", addAttrExpressionObject.getExpression());
+
+ Attribute addListAttribute = listValue.get(1);
+ Assert.assertEquals("list-list-attr-role", addListAttribute.getRole());
+ List<Attribute> addListValue = getListValue(addListAttribute);
+ Assert.assertEquals(1, addListValue.size());
+ Assert.assertEquals("list-list-add-attr", addListValue.get(0).getValue());
+
+ Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
+ Assert.assertEquals(2, cascadedAttributeNames.size());
+ Assert.assertTrue(cascadedAttributeNames.contains("put-attr"));
+ Assert.assertTrue(cascadedAttributeNames.contains("list-name"));
+ }
+
+ @Test
+ public void buildDefinitonAllEmpty() {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotationAllEmpty(), null);
+
+ Definition definition = annotationProcessor.buildTilesDefinition(null, tilesDefinition);
+
+ Assert.assertNotNull(definition);
+ Assert.assertNull(definition.getName());
+ Assert.assertNull(definition.getPreparer());
+ Assert.assertNull(definition.getExtends());
+ Attribute templateAttribute = definition.getTemplateAttribute();
+ Assert.assertNull(templateAttribute.getValue());
+ //Assert.assertNull(templateAttribute.getRenderer());
+ Assert.assertNull(templateAttribute.getRole());
+ Assert.assertNull(templateAttribute.getExpressionObject());
+
+ Attribute putAttribute = definition.getAttribute("put-attr");
+ Assert.assertNotNull(putAttribute);
+ Assert.assertNull(putAttribute.getValue());
+ Assert.assertNull(putAttribute.getRenderer());
+ Assert.assertNull(putAttribute.getRole());
+ Assert.assertNull(putAttribute.getExpressionObject());
+
+ Attribute listAttribute = definition.getAttribute("list-name");
+ Assert.assertNull(listAttribute.getRole());
+ List<Attribute> listValue = getListValue(listAttribute);
+ Assert.assertEquals(2, listValue.size());
+
+ Attribute addAttribute = listValue.get(0);
+ Assert.assertNull(addAttribute.getRole());
+ Assert.assertNull(addAttribute.getValue());
+ Assert.assertNull(addAttribute.getRenderer());
+ Assert.assertNull(addAttribute.getExpressionObject());
+
+ Attribute addListAttribute = listValue.get(1);
+ Assert.assertNull(addListAttribute.getRole());
+ List<Attribute> addListValue = getListValue(addListAttribute);
+ Assert.assertEquals(1, addListValue.size());
+ Assert.assertNull(addListValue.get(0).getValue());
+
+ Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
+ Assert.assertNull(cascadedAttributeNames);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List<Attribute> getListValue(Attribute listAttribute) {
+ return (List<Attribute>) listAttribute.getValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ca6eb98/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
deleted file mode 100644
index db808cd..0000000
--- a/plugins/tiles/src/test/java/org/apache/struts2/tiles/TestStrutsTilesAnnotationProcessor.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.apache.struts2.tiles;
-
-import java.util.List;
-import java.util.Set;
-
-import org.apache.struts2.tiles.annotation.TilesDefinition;
-import org.apache.tiles.Attribute;
-import org.apache.tiles.Definition;
-import org.apache.tiles.Expression;
-import org.junit.Test;
-
-import org.junit.Assert;
-
-public class TestStrutsTilesAnnotationProcessor {
-
- @Test
- public void findAnnotationSingleAction() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
- Assert.assertNotNull(tilesDefinition);
- Assert.assertEquals("definition-name", tilesDefinition.name());
- }
-
- @Test
- public void findAnnotationMultipleActionNameNull() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), null);
- Assert.assertNotNull(tilesDefinition);
- Assert.assertEquals("def1", tilesDefinition.name());
- }
-
- @Test
- public void findAnnotationMultipleActionNameGiven() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def2");
- Assert.assertNotNull(tilesDefinition);
- Assert.assertEquals("def2", tilesDefinition.name());
- }
-
- @Test
- public void findAnnotationMultipleActionNotFound() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionMultipleAnnotations(), "def3");
- Assert.assertNull(tilesDefinition);
- }
-
- @Test
- public void buildDefiniton() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotation(), null);
-
- Definition definition = annotationProcessor.buildTilesDefinition("tileName", tilesDefinition);
-
- Assert.assertNotNull(definition);
- Assert.assertEquals("tileName", definition.getName());
- Assert.assertEquals("preparer", definition.getPreparer());
- Assert.assertEquals("base-definition", definition.getExtends());
- Attribute templateAttribute = definition.getTemplateAttribute();
- Assert.assertEquals("template", templateAttribute.getValue());
- Assert.assertEquals("type", templateAttribute.getRenderer());
- Assert.assertEquals("role", templateAttribute.getRole());
- Expression definitionExpressionObject = templateAttribute.getExpressionObject();
- Assert.assertEquals("templ*", definitionExpressionObject.getExpression());
- Assert.assertNull(definitionExpressionObject.getLanguage());
-
- Attribute putAttribute = definition.getAttribute("put-attr");
- Assert.assertNotNull(putAttribute);
- Assert.assertEquals("attr-val", putAttribute.getValue());
- Assert.assertEquals("attr-type", putAttribute.getRenderer());
- Assert.assertEquals("attr-role", putAttribute.getRole());
- Expression putAttrExpressionObject = putAttribute.getExpressionObject();
- Assert.assertEquals("expr", putAttrExpressionObject.getExpression());
- Assert.assertEquals("lang", putAttrExpressionObject.getLanguage());
-
- Attribute listAttribute = definition.getAttribute("list-name");
- Assert.assertEquals("list-role", listAttribute.getRole());
- List<Attribute> listValue = getListValue(listAttribute);
- Assert.assertEquals(2, listValue.size());
-
- Attribute addAttribute = listValue.get(0);
- Assert.assertEquals("list-attr-role", addAttribute.getRole());
- Assert.assertEquals("list-attr-val", addAttribute.getValue());
- Assert.assertEquals("list-attr-type", addAttribute.getRenderer());
- Expression addAttrExpressionObject = addAttribute.getExpressionObject();
- Assert.assertEquals("list-attr-expr", addAttrExpressionObject.getExpression());
-
- Attribute addListAttribute = listValue.get(1);
- Assert.assertEquals("list-list-attr-role", addListAttribute.getRole());
- List<Attribute> addListValue = getListValue(addListAttribute);
- Assert.assertEquals(1, addListValue.size());
- Assert.assertEquals("list-list-add-attr", addListValue.get(0).getValue());
-
- Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
- Assert.assertEquals(2, cascadedAttributeNames.size());
- Assert.assertTrue(cascadedAttributeNames.contains("put-attr"));
- Assert.assertTrue(cascadedAttributeNames.contains("list-name"));
- }
-
- @Test
- public void buildDefinitonAllEmpty() {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = annotationProcessor.findAnnotation(new TilesTestActionSingleAnnotationAllEmpty(), null);
-
- Definition definition = annotationProcessor.buildTilesDefinition(null, tilesDefinition);
-
- Assert.assertNotNull(definition);
- Assert.assertNull(definition.getName());
- Assert.assertNull(definition.getPreparer());
- Assert.assertNull(definition.getExtends());
- Attribute templateAttribute = definition.getTemplateAttribute();
- Assert.assertNull(templateAttribute.getValue());
- //Assert.assertNull(templateAttribute.getRenderer());
- Assert.assertNull(templateAttribute.getRole());
- Assert.assertNull(templateAttribute.getExpressionObject());
-
- Attribute putAttribute = definition.getAttribute("put-attr");
- Assert.assertNotNull(putAttribute);
- Assert.assertNull(putAttribute.getValue());
- Assert.assertNull(putAttribute.getRenderer());
- Assert.assertNull(putAttribute.getRole());
- Assert.assertNull(putAttribute.getExpressionObject());
-
- Attribute listAttribute = definition.getAttribute("list-name");
- Assert.assertNull(listAttribute.getRole());
- List<Attribute> listValue = getListValue(listAttribute);
- Assert.assertEquals(2, listValue.size());
-
- Attribute addAttribute = listValue.get(0);
- Assert.assertNull(addAttribute.getRole());
- Assert.assertNull(addAttribute.getValue());
- Assert.assertNull(addAttribute.getRenderer());
- Assert.assertNull(addAttribute.getExpressionObject());
-
- Attribute addListAttribute = listValue.get(1);
- Assert.assertNull(addListAttribute.getRole());
- List<Attribute> addListValue = getListValue(addListAttribute);
- Assert.assertEquals(1, addListValue.size());
- Assert.assertNull(addListValue.get(0).getValue());
-
- Set<String> cascadedAttributeNames = definition.getCascadedAttributeNames();
- Assert.assertNull(cascadedAttributeNames);
- }
-
- @SuppressWarnings("unchecked")
- protected List<Attribute> getListValue(Attribute listAttribute) {
- return (List<Attribute>) listAttribute.getValue();
- }
-}
[08/13] struts git commit: formatted annotations more nicely
Posted by cn...@apache.org.
formatted annotations more nicely
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/edf7c099
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/edf7c099
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/edf7c099
Branch: refs/heads/master
Commit: edf7c099e3ed6ee17008a738ef8801c854139fd1
Parents: 9ca6eb9
Author: cnenning <cn...@apache.org>
Authored: Mon Feb 1 09:36:23 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Feb 1 09:36:23 2016 +0100
----------------------------------------------------------------------
.../apache/struts2/showcase/tiles/TilesAnnotationsAction.java | 5 +++--
.../org/apache/struts2/tiles/annotation/TilesDefinition.java | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/edf7c099/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
index 997db11..b5c62f0 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -12,8 +12,9 @@ import com.opensymphony.xwork2.ActionSupport;
@ParentPackage("tiles")
@Result(name = "success", type="tiles")
@TilesDefinition(extend = "showcase.annotations", putAttributes = {
- @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
- @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), })
+ @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
+ @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl")
+})
public class TilesAnnotationsAction extends ActionSupport {
private static final long serialVersionUID = 2900509995064928866L;
http://git-wip-us.apache.org/repos/asf/struts/blob/edf7c099/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
index 1618b63..3aa144c 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -42,7 +42,8 @@ import java.lang.annotation.Target;
* @Result(name = "success", type="tiles")
* @TilesDefinition(extend = "layout", putAttributes = {
* @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
- * @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), })
+ * @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl")
+ * })
* public class FooAction extends ActionSupport {
* </pre>
* </p>
[06/13] struts git commit: fixed line endings
Posted by cn...@apache.org.
fixed line endings
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b1588ddc
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b1588ddc
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b1588ddc
Branch: refs/heads/master
Commit: b1588ddc84d876a676bab66ad80ec34637e98536
Parents: a53deac
Author: cnenning <cn...@apache.org>
Authored: Mon Jan 25 13:50:45 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Jan 25 13:50:45 2016 +0100
----------------------------------------------------------------------
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 108 +++---
.../src/main/webapp/WEB-INF/tiles/body.jsp | 52 +--
.../apache/struts2/views/tiles/TilesResult.java | 326 +++++++++----------
3 files changed, 243 insertions(+), 243 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index d644502..a74de1b 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -1,54 +1,54 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<!--
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- *
- */
--->
-
-<!DOCTYPE tiles-definitions PUBLIC
- "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
- "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
-
-<tiles-definitions>
-
- <definition name="showcase.index" template="/WEB-INF/tiles/layout.jsp">
- <put-attribute name="title" value="Tiles Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/>
- </definition>
-
- <definition name="showcase.freemarker" template="/WEB-INF/tiles/layout.jsp">
- <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
- </definition>
-
- <definition name="showcase.freemarkerLayout" template="/WEB-INF/tiles/layout.ftl">
- <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
- <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
- <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
- </definition>
-
- <definition name="showcase.annotations" template="/WEB-INF/tiles/layout-annotations.jsp">
- <put-attribute name="title" value="Tiles Annotations Showcase"/>
- <put-attribute name="header" value=".header"/>
- <put-attribute name="body" value=".body"/>
- </definition>
-
-</tiles-definitions>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+-->
+
+<!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
+ "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
+
+<tiles-definitions>
+
+ <definition name="showcase.index" template="/WEB-INF/tiles/layout.jsp">
+ <put-attribute name="title" value="Tiles Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.jsp"/>
+ </definition>
+
+ <definition name="showcase.freemarker" template="/WEB-INF/tiles/layout.jsp">
+ <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
+ </definition>
+
+ <definition name="showcase.freemarkerLayout" template="/WEB-INF/tiles/layout.ftl">
+ <put-attribute name="title" value="Tiles/Freemarker Showcase"/>
+ <put-attribute name="header" value="/WEB-INF/tiles/header.jsp"/>
+ <put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
+ </definition>
+
+ <definition name="showcase.annotations" template="/WEB-INF/tiles/layout-annotations.jsp">
+ <put-attribute name="title" value="Tiles Annotations Showcase"/>
+ <put-attribute name="header" value=".header"/>
+ <put-attribute name="body" value=".body"/>
+ </definition>
+
+</tiles-definitions>
http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
index ca9d10d..855a896 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
@@ -1,27 +1,27 @@
-<%@taglib prefix="s" uri="/struts-tags" %>
-<div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <div>
- <p>This example illustrates the Struts/Tiles Plugin.</p>
-
- <p>Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed
- in the Sandbox area of the Apache Struts Subversion repository.</p>
-
- <h4>Features</h4>
- <ul>
- <li>
- <a href="freemarker.action">View FreeMarker Example</a>
- </li>
- <li>
- <a href="freemarkerLayout.action">View Example with a FreeMarker Layout</a>
- </li>
- <li>
- <a href="tiles-annotations.action">View Example with tiles configuration by annotating action</a>
- </li>
- </ul>
-
- </div>
- </div>
- </div>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<div class="container-fluid">
+ <div class="row">
+ <div class="col-md-12">
+ <div>
+ <p>This example illustrates the Struts/Tiles Plugin.</p>
+
+ <p>Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed
+ in the Sandbox area of the Apache Struts Subversion repository.</p>
+
+ <h4>Features</h4>
+ <ul>
+ <li>
+ <a href="freemarker.action">View FreeMarker Example</a>
+ </li>
+ <li>
+ <a href="freemarkerLayout.action">View Example with a FreeMarker Layout</a>
+ </li>
+ <li>
+ <a href="tiles-annotations.action">View Example with tiles configuration by annotating action</a>
+ </li>
+ </ul>
+
+ </div>
+ </div>
+ </div>
</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/b1588ddc/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index da00765..4656f91 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -1,163 +1,163 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-package org.apache.struts2.views.tiles;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.result.ServletDispatcherResult;
-import org.apache.struts2.tiles.StrutsTilesAnnotationProcessor;
-import org.apache.struts2.tiles.annotation.TilesDefinition;
-import org.apache.tiles.Definition;
-import org.apache.tiles.TilesContainer;
-import org.apache.tiles.TilesException;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.mgmt.MutableTilesContainer;
-import org.apache.tiles.request.ApplicationContext;
-import org.apache.tiles.request.Request;
-import org.apache.tiles.request.servlet.ServletRequest;
-import org.apache.tiles.request.servlet.ServletUtil;
-
-/**
- * <!-- START SNIPPET: description -->
- * Renders a view using struts-tiles.
- * <!-- END SNIPPET: description -->
- *
- * <!-- START SNIPPET: webxml -->
- * In your web.xml file, you need to add a TilesListener.
- *
- * <listener>
- * <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
- * </listener>
- * <!-- END SNIPPET: webxml -->
- *
- * <!-- START SNIPPET: strutsxml -->
- * In struts.xml, use type="tiles" on your <result>.
- *
- * <action name="editUser" class="userAction" method="edit">
- * <result name="success" type="tiles">userForm</result>
- * <result name="input" type="tiles">userList</result>
- * </action>
- * <!-- END SNIPPET: strutsxml -->
- *
- *
- * <!-- START SNIPPET: packageconfig -->
- *
- * Making this result type the default for the current package.
- *
- * <result-types>
- * <result-type name="tiles"
- * class="org.apache.struts2.views.tiles.TilesResult" default="true" />
- * </result-types>
- * <!-- END SNIPPET: packageconfig -->
- *
- *
- * <!-- START SNIPPET: tilesconfig -->
- * You have to configure tiles itself. Therefore you can add <code>tiles.xml</code> either
- * to resources or WEB-INF. You may also use annotations like {@link TilesDefinition}.
- *
- * <!-- END SNIPPET: tilesconfig -->
- *
- */
-public class TilesResult extends ServletDispatcherResult {
-
- private static final long serialVersionUID = -3806939435493086244L;
-
- private static final Logger LOG = LogManager.getLogger(TilesResult.class);
-
- public TilesResult() {
- super();
- }
-
- public TilesResult(String location) {
- super(location);
- }
-
- /**
- * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
- * dispatch fails a 404 error will be sent back in the http response.
- *
- * @param location the location to dispatch to.
- * @param invocation the execution state of the action
- * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
- * HTTP request.
- */
- public void doExecute(String location, ActionInvocation invocation) throws Exception {
- StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
- TilesDefinition tilesDefinition = null;
- Object action = invocation.getAction();
- String actionName = invocation.getInvocationContext().getName();
-
- if (StringUtils.isEmpty(location)) {
- // location not set -> action must have one @TilesDefinition
- tilesDefinition = annotationProcessor.findAnnotation(action, null);
- String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? tilesDefinition.name() : actionName;
- location = tileName;
- LOG.debug("using new location name '{}' and @TilesDefinition '{}'", location, tilesDefinition);
- }
- setLocation(location);
-
- ServletContext servletContext = ServletActionContext.getServletContext();
-
- ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
- TilesContainer container = TilesAccess.getContainer(applicationContext);
-
- HttpServletRequest httpRequest = ServletActionContext.getRequest();
- HttpServletResponse httpResponse = ServletActionContext.getResponse();
-
- Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
-
- boolean definitionValid = false;
- try {
- LOG.debug("checking if tiles definition exists '{}'", location);
- definitionValid = container.isValidDefinition(location, request);
- } catch (TilesException e) {
- LOG.warn("got TilesException while checking if definiton exists, ignoring it", e);
- }
- if (!definitionValid) {
- if (tilesDefinition == null) {
- // tilesDefinition not found yet, search in action
- tilesDefinition = annotationProcessor.findAnnotation(action, location);
- }
- if (tilesDefinition != null) {
- Definition definition = annotationProcessor.buildTilesDefinition(location, tilesDefinition);
- if (container instanceof MutableTilesContainer) {
- LOG.debug("registering tiles definition with name '{}'", definition.getName());
- ((MutableTilesContainer)container).register(definition, request);
- } else {
- LOG.error("cannot register tiles definition as tiles container is not mutable!");
- }
- } else {
- LOG.warn("could not find @TilesDefinition for action: {}", actionName);
- }
- }
-
- container.render(location, request);
- }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.struts2.views.tiles;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.result.ServletDispatcherResult;
+import org.apache.struts2.tiles.StrutsTilesAnnotationProcessor;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Definition;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.mgmt.MutableTilesContainer;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.servlet.ServletRequest;
+import org.apache.tiles.request.servlet.ServletUtil;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * Renders a view using struts-tiles.
+ * <!-- END SNIPPET: description -->
+ *
+ * <!-- START SNIPPET: webxml -->
+ * In your web.xml file, you need to add a TilesListener.
+ *
+ * <listener>
+ * <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
+ * </listener>
+ * <!-- END SNIPPET: webxml -->
+ *
+ * <!-- START SNIPPET: strutsxml -->
+ * In struts.xml, use type="tiles" on your <result>.
+ *
+ * <action name="editUser" class="userAction" method="edit">
+ * <result name="success" type="tiles">userForm</result>
+ * <result name="input" type="tiles">userList</result>
+ * </action>
+ * <!-- END SNIPPET: strutsxml -->
+ *
+ *
+ * <!-- START SNIPPET: packageconfig -->
+ *
+ * Making this result type the default for the current package.
+ *
+ * <result-types>
+ * <result-type name="tiles"
+ * class="org.apache.struts2.views.tiles.TilesResult" default="true" />
+ * </result-types>
+ * <!-- END SNIPPET: packageconfig -->
+ *
+ *
+ * <!-- START SNIPPET: tilesconfig -->
+ * You have to configure tiles itself. Therefore you can add <code>tiles.xml</code> either
+ * to resources or WEB-INF. You may also use annotations like {@link TilesDefinition}.
+ *
+ * <!-- END SNIPPET: tilesconfig -->
+ *
+ */
+public class TilesResult extends ServletDispatcherResult {
+
+ private static final long serialVersionUID = -3806939435493086244L;
+
+ private static final Logger LOG = LogManager.getLogger(TilesResult.class);
+
+ public TilesResult() {
+ super();
+ }
+
+ public TilesResult(String location) {
+ super(location);
+ }
+
+ /**
+ * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
+ * dispatch fails a 404 error will be sent back in the http response.
+ *
+ * @param location the location to dispatch to.
+ * @param invocation the execution state of the action
+ * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
+ * HTTP request.
+ */
+ public void doExecute(String location, ActionInvocation invocation) throws Exception {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = null;
+ Object action = invocation.getAction();
+ String actionName = invocation.getInvocationContext().getName();
+
+ if (StringUtils.isEmpty(location)) {
+ // location not set -> action must have one @TilesDefinition
+ tilesDefinition = annotationProcessor.findAnnotation(action, null);
+ String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? tilesDefinition.name() : actionName;
+ location = tileName;
+ LOG.debug("using new location name '{}' and @TilesDefinition '{}'", location, tilesDefinition);
+ }
+ setLocation(location);
+
+ ServletContext servletContext = ServletActionContext.getServletContext();
+
+ ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
+ TilesContainer container = TilesAccess.getContainer(applicationContext);
+
+ HttpServletRequest httpRequest = ServletActionContext.getRequest();
+ HttpServletResponse httpResponse = ServletActionContext.getResponse();
+
+ Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
+
+ boolean definitionValid = false;
+ try {
+ LOG.debug("checking if tiles definition exists '{}'", location);
+ definitionValid = container.isValidDefinition(location, request);
+ } catch (TilesException e) {
+ LOG.warn("got TilesException while checking if definiton exists, ignoring it", e);
+ }
+ if (!definitionValid) {
+ if (tilesDefinition == null) {
+ // tilesDefinition not found yet, search in action
+ tilesDefinition = annotationProcessor.findAnnotation(action, location);
+ }
+ if (tilesDefinition != null) {
+ Definition definition = annotationProcessor.buildTilesDefinition(location, tilesDefinition);
+ if (container instanceof MutableTilesContainer) {
+ LOG.debug("registering tiles definition with name '{}'", definition.getName());
+ ((MutableTilesContainer)container).register(definition, request);
+ } else {
+ LOG.error("cannot register tiles definition as tiles container is not mutable!");
+ }
+ } else {
+ LOG.warn("could not find @TilesDefinition for action: {}", actionName);
+ }
+ }
+
+ container.render(location, request);
+ }
+}
[03/13] struts git commit: added sample for tiles annotations
Posted by cn...@apache.org.
added sample for tiles annotations
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e50c37c5
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e50c37c5
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e50c37c5
Branch: refs/heads/master
Commit: e50c37c5ba5781900edf53f9ec71b8649471d448
Parents: 9ac326a
Author: cnenning <cn...@apache.org>
Authored: Fri Jan 22 15:27:50 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Fri Jan 22 15:27:50 2016 +0100
----------------------------------------------------------------------
.../showcase/tiles/TilesAnnotationsAction.java | 21 +++++++++
apps/showcase/src/main/webapp/WEB-INF/tiles.xml | 6 +++
.../src/main/webapp/WEB-INF/tiles/body.jsp | 49 +++++++++++---------
.../webapp/WEB-INF/tiles/layout-annotations.jsp | 14 ++++++
4 files changed, 67 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
new file mode 100644
index 0000000..997db11
--- /dev/null
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tiles/TilesAnnotationsAction.java
@@ -0,0 +1,21 @@
+package org.apache.struts2.showcase.tiles;
+
+import org.apache.struts2.convention.annotation.Namespace;
+import org.apache.struts2.convention.annotation.ParentPackage;
+import org.apache.struts2.convention.annotation.Result;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+@Namespace("/tiles")
+@ParentPackage("tiles")
+@Result(name = "success", type="tiles")
+@TilesDefinition(extend = "showcase.annotations", putAttributes = {
+ @TilesPutAttribute(name = "header", value = "/WEB-INF/tiles/header.jsp"),
+ @TilesPutAttribute(name = "body", value = "/WEB-INF/tiles/body.ftl"), })
+public class TilesAnnotationsAction extends ActionSupport {
+
+ private static final long serialVersionUID = 2900509995064928866L;
+
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
index 027f9a4..d644502 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles.xml
@@ -45,4 +45,10 @@
<put-attribute name="body" value="/WEB-INF/tiles/body.ftl"/>
</definition>
+ <definition name="showcase.annotations" template="/WEB-INF/tiles/layout-annotations.jsp">
+ <put-attribute name="title" value="Tiles Annotations Showcase"/>
+ <put-attribute name="header" value=".header"/>
+ <put-attribute name="body" value=".body"/>
+ </definition>
+
</tiles-definitions>
http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
index e2e3512..ca9d10d 100644
--- a/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/body.jsp
@@ -1,24 +1,27 @@
-<%@taglib prefix="s" uri="/struts-tags" %>
-<div class="container-fluid">
- <div class="row">
- <div class="col-md-12">
- <div>
- <p>This example illustrates the Struts/Tiles Plugin.</p>
-
- <p>Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed
- in the Sandbox area of the Apache Struts Subversion repository.</p>
-
- <h4>Features</h4>
- <ul>
- <li>
- <a href="freemarker.action">View FreeMarker Example</a>
- </li>
- <li>
- <a href="freemarkerLayout.action">View Example with a FreeMarker Layout</a>
- </li>
- </ul>
-
- </div>
- </div>
- </div>
+<%@taglib prefix="s" uri="/struts-tags" %>
+<div class="container-fluid">
+ <div class="row">
+ <div class="col-md-12">
+ <div>
+ <p>This example illustrates the Struts/Tiles Plugin.</p>
+
+ <p>Tiles 2 is an effort to extract the Tiles library from Struts. It is currently housed
+ in the Sandbox area of the Apache Struts Subversion repository.</p>
+
+ <h4>Features</h4>
+ <ul>
+ <li>
+ <a href="freemarker.action">View FreeMarker Example</a>
+ </li>
+ <li>
+ <a href="freemarkerLayout.action">View Example with a FreeMarker Layout</a>
+ </li>
+ <li>
+ <a href="tiles-annotations.action">View Example with tiles configuration by annotating action</a>
+ </li>
+ </ul>
+
+ </div>
+ </div>
+ </div>
</div>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/e50c37c5/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
----------------------------------------------------------------------
diff --git a/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp b/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
new file mode 100644
index 0000000..5609cb1
--- /dev/null
+++ b/apps/showcase/src/main/webapp/WEB-INF/tiles/layout-annotations.jsp
@@ -0,0 +1,14 @@
+<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+
+<%-- Show usage; Used in Header --%>
+<tiles:importAttribute name="title" scope="request"/>
+<html>
+ <head><title>Struts2 Showcase - <tiles:getAsString name="title"/></title></head>
+<body>
+ <tiles:insertAttribute name="header"/>
+ <tiles:insertAttribute name="body"/>
+ <p>Notice that this is a layout made in JSP</p>
+ <p>It is configured with <strong>annotations!</strong></p>
+</body>
+</html>
[02/13] struts git commit: Added tiles annotations, see WW-4594.
Posted by cn...@apache.org.
Added tiles annotations, see WW-4594.
Added tiles annotations, created StrutsTilesAnnotationProcessor to
create Definitons from them and using it in TilesResult.
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/9ac326aa
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/9ac326aa
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/9ac326aa
Branch: refs/heads/master
Commit: 9ac326aa2458fe43140c1b13b61c87752d282e3d
Parents: d9f4054
Author: cnenning <cn...@apache.org>
Authored: Fri Jan 22 15:27:09 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Fri Jan 22 15:27:09 2016 +0100
----------------------------------------------------------------------
.../tiles/StrutsTilesAnnotationProcessor.java | 176 ++++++++++++
.../tiles/annotation/TilesAddAttribute.java | 30 ++
.../tiles/annotation/TilesAddListAttribute.java | 28 ++
.../tiles/annotation/TilesDefinition.java | 45 +++
.../tiles/annotation/TilesDefinitions.java | 36 +++
.../tiles/annotation/TilesPutAttribute.java | 32 +++
.../tiles/annotation/TilesPutListAttribute.java | 32 +++
.../apache/struts2/views/tiles/TilesResult.java | 279 +++++++++++--------
8 files changed, 542 insertions(+), 116 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
new file mode 100644
index 0000000..2ae3ba4
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessor.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.struts2.tiles.annotation.TilesAddAttribute;
+import org.apache.struts2.tiles.annotation.TilesAddListAttribute;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.struts2.tiles.annotation.TilesDefinitions;
+import org.apache.struts2.tiles.annotation.TilesPutAttribute;
+import org.apache.struts2.tiles.annotation.TilesPutListAttribute;
+import org.apache.tiles.Attribute;
+import org.apache.tiles.Definition;
+import org.apache.tiles.Expression;
+import org.apache.tiles.ListAttribute;
+
+/**
+ * Processes tiles annotations to create {@link Definition}s and
+ * {@link Attribute}s in a way as close to <code>tiles.xml</code> as possible.
+ *
+ */
+public class StrutsTilesAnnotationProcessor {
+
+ /**
+ * Search strategy is as follows:
+ * <ul>
+ * <li>Check if action has Annotation {@link TilesDefinition}</li>
+ * <li>If not, check if action has Annotation {@link TilesDefinitions}</li>
+ * <li>If given tileName is not null and present in {@link TilesDefinitions}, return it</li>
+ * <li>Return first element of {@link TilesDefinitions}</li>
+ * <li>Return null</li>
+ * </ul>
+ *
+ * @param action
+ * Annotated action.
+ * @param tileName
+ * Tilename to search for. May be null in some circumstances.
+ * @return {@link TilesDefinition}
+ */
+ public TilesDefinition findAnnotation(Object action, String tileName) {
+ Class<? extends Object> clazz = action.getClass();
+ TilesDefinition tilesDefinition = clazz.getAnnotation(TilesDefinition.class);
+ TilesDefinitions tilesDefinitions = clazz.getAnnotation(TilesDefinitions.class);
+
+ if (tilesDefinition == null && tilesDefinitions != null) {
+ if (!StringUtils.isEmpty(tileName)) {
+ for (TilesDefinition i : tilesDefinitions.value()) {
+ if (i.name() != null && i.name().equals(tileName)) {
+ tilesDefinition = i;
+ break;
+ }
+ }
+ }
+ if (tilesDefinitions.value().length > 0) {
+ tilesDefinition = tilesDefinitions.value()[0];
+ }
+ }
+
+ return tilesDefinition;
+ }
+
+ /**
+ * Builds a {@link Definition} based on given {@link TilesDefinition} with
+ * given name.
+ *
+ * @param tileName
+ * name for resulting {@link Definition}.
+ * @param tilesDefinition
+ * {@link TilesDefinition} to process.
+ * @return {@link Definition} represented by given {@link TilesDefinition}.
+ */
+ public Definition buildTilesDefinition(String tileName, TilesDefinition tilesDefinition) {
+ Definition definition = new Definition();
+
+ definition.setName(tileName);
+
+ String extend = getValueOrNull(tilesDefinition.extend());
+ if (extend != null) {
+ definition.setExtends(extend);
+ }
+ String preparer = getValueOrNull(tilesDefinition.preparer());
+ if (preparer != null) {
+ definition.setPreparer(preparer);
+ }
+ definition.setTemplateAttribute(buildTemplateAttribute(tilesDefinition));
+
+ for (TilesPutAttribute putAttribute : tilesDefinition.putAttributes()) {
+ Attribute attribute = buildPutAttribute(putAttribute);
+ definition.putAttribute(putAttribute.name(), attribute, putAttribute.cascade());
+ }
+ for (TilesPutListAttribute putListAttribute : tilesDefinition.putListAttributes()) {
+ Attribute attribute = buildPutListAttribute(putListAttribute);
+ definition.putAttribute(putListAttribute.name(), attribute, putListAttribute.cascade());
+ }
+
+ return definition;
+ }
+
+ protected Attribute buildTemplateAttribute(TilesDefinition tilesDef) {
+ // see tiles DigesterDefinitionsReader
+ Attribute attribute = Attribute.createTemplateAttribute(getValueOrNull(tilesDef.template()));
+ String templateExpression = getValueOrNull(tilesDef.templateExpression());
+ Expression expression = Expression.createExpressionFromDescribedExpression(templateExpression);
+ attribute.setExpressionObject(expression);
+ attribute.setRole(getValueOrNull(tilesDef.role()));
+ String templateType = getValueOrNull(tilesDef.templateType());
+ if (templateType != null) {
+ attribute.setRenderer(templateType);
+ } else if (getValueOrNull(tilesDef.extend()) != null && templateType == null) {
+ attribute.setRenderer(null);
+ }
+ return attribute;
+ }
+
+ protected Attribute buildPutAttribute(TilesPutAttribute putAttribute) {
+ Attribute attribute = new Attribute();
+ attribute.setValue(getValueOrNull(putAttribute.value()));
+ String expression = getValueOrNull(putAttribute.expression());
+ attribute.setExpressionObject(Expression.createExpressionFromDescribedExpression(expression));
+ attribute.setRole(getValueOrNull(putAttribute.role()));
+ attribute.setRenderer(getValueOrNull(putAttribute.type()));
+ return attribute;
+ }
+
+ protected Attribute buildPutListAttribute(TilesPutListAttribute putListAttribute) {
+ ListAttribute attribute = new ListAttribute();
+ attribute.setRole(getValueOrNull(putListAttribute.role()));
+ attribute.setInherit(putListAttribute.inherit());
+ for (TilesAddAttribute addAttribute : putListAttribute.addAttributes()) {
+ attribute.add(buildAddAttribute(addAttribute));
+ }
+ for (TilesAddListAttribute addListAttribute : putListAttribute.addListAttributes()) {
+ attribute.add(buildAddListAttribute(addListAttribute));
+ }
+ return attribute;
+ }
+
+ protected Attribute buildAddAttribute(TilesAddAttribute addAttribute) {
+ Attribute attribute = new Attribute();
+ attribute.setValue(getValueOrNull(addAttribute.value()));
+ String expression = getValueOrNull(addAttribute.expression());
+ attribute.setExpressionObject(Expression.createExpressionFromDescribedExpression(expression));
+ attribute.setRole(getValueOrNull(addAttribute.role()));
+ attribute.setRenderer(getValueOrNull(addAttribute.type()));
+ return attribute;
+ }
+
+ protected Attribute buildAddListAttribute(TilesAddListAttribute addListAttribute) {
+ ListAttribute attribute = new ListAttribute();
+ attribute.setRole(getValueOrNull(addListAttribute.role()));
+ for (TilesAddAttribute addAttribute : addListAttribute.addAttributes()) {
+ attribute.add(buildAddAttribute(addAttribute));
+ }
+ return attribute;
+ }
+
+ protected String getValueOrNull(String value) {
+ return value != null && value.length() > 0 ? value : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddAttribute.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddAttribute.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddAttribute.java
new file mode 100644
index 0000000..0e668de
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddAttribute.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+/**
+ * Represents a <code><add-attribute></code> element in <code>tiles.xml</code>.
+ *
+ */
+public @interface TilesAddAttribute {
+ String expression() default "";
+ String role() default "";
+ String type() default "";
+ String value() default "";
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddListAttribute.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddListAttribute.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddListAttribute.java
new file mode 100644
index 0000000..d65066f
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesAddListAttribute.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+/**
+ * Represents a <code><add-list-attribute></code> element in <code>tiles.xml</code>.
+ *
+ */
+public @interface TilesAddListAttribute {
+ String role() default "";
+ TilesAddAttribute[] addAttributes() default {};
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
new file mode 100644
index 0000000..a71bbc3
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinition.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Represents a <code><definition></code> element in <code>tiles.xml</code>.
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+@Inherited
+public @interface TilesDefinition {
+
+ String extend() default "";
+ String name() default "";
+ String preparer() default "";
+ String role() default "";
+ String template() default "";
+ String templateExpression() default "";
+ String templateType() default "";
+ TilesPutAttribute[] putAttributes() default {};
+ TilesPutListAttribute[] putListAttributes() default {};
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinitions.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinitions.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinitions.java
new file mode 100644
index 0000000..fb5cc95
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesDefinitions.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An array of {@link TilesDefinition}s.
+ *
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+@Inherited
+public @interface TilesDefinitions {
+ TilesDefinition[] value();
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutAttribute.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutAttribute.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutAttribute.java
new file mode 100644
index 0000000..c31d49e
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutAttribute.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+/**
+ * Represents a <code><put-attribute></code> element in <code>tiles.xml</code>.
+ *
+ */
+public @interface TilesPutAttribute {
+ boolean cascade() default false;
+ String expression() default "";
+ String name() default "";
+ String role() default "";
+ String type() default "";
+ String value() default "";
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutListAttribute.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutListAttribute.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutListAttribute.java
new file mode 100644
index 0000000..be7a507
--- /dev/null
+++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/annotation/TilesPutListAttribute.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.struts2.tiles.annotation;
+
+/**
+ * Represents a <code><put-list-attribute></code> element in <code>tiles.xml</code>.
+ *
+ */
+public @interface TilesPutListAttribute {
+ boolean cascade() default false;
+ boolean inherit() default false;
+ String name() default "";
+ String role() default "";
+ TilesAddAttribute[] addAttributes() default {};
+ TilesAddListAttribute[] addListAttributes() default {};
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/9ac326aa/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
index a402869..da00765 100644
--- a/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
+++ b/plugins/tiles/src/main/java/org/apache/struts2/views/tiles/TilesResult.java
@@ -1,116 +1,163 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-package org.apache.struts2.views.tiles;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.result.ServletDispatcherResult;
-import org.apache.tiles.TilesContainer;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import org.apache.tiles.access.TilesAccess;
-import org.apache.tiles.request.ApplicationContext;
-import org.apache.tiles.request.Request;
-import org.apache.tiles.request.servlet.ServletRequest;
-import org.apache.tiles.request.servlet.ServletUtil;
-
-/**
- * <!-- START SNIPPET: description -->
- * Renders a view using struts-tiles.
- * <!-- END SNIPPET: description -->
- *
- * <!-- START SNIPPET: webxml -->
- * In your web.xml file, you need to add a servlet entry for TilesServlet to load the tiles
- * definitions into the ServletContext.
- *
- * <servlet>
- * <servlet-name>tiles</servlet-name>
- * <servlet-class>org.apache.tiles.servlets.TilesServlet</servlet-class>
- * <init-param>
- * <param-name>definitions-config</param-name>
- * <param-value>/WEB-INF/tiles-config.xml</param-value>
- * </init-param>
- * <load-on-startup>1</load-on-startup>
- * </servlet>
- * <!-- END SNIPPET: webxml -->
- *
- * <!-- START SNIPPET: strutsxml -->
- * In struts.xml, use type="tiles" on your <result>.
- *
- * <action name="editUser" class="userAction" method="edit">
- * <result name="success" type="tiles">userForm</result>
- * <result name="input" type="tiles">userList</result>
- * </action>
- * <!-- END SNIPPET: strutsxml -->
- *
- *
- * <!-- START SNIPPET: packageconfig -->
- *
- * Making this result type the default for the current package.
- *
- * <result-types>
- * <result-type name="tiles"
- * class="org.apache.struts2.views.tiles.TilesResult" default="true" />
- * </result-types>
- * <!-- END SNIPPET: packageconfig -->
- *
- */
-public class TilesResult extends ServletDispatcherResult {
-
- private static final long serialVersionUID = -3806939435493086244L;
-
- public TilesResult() {
- super();
- }
-
- public TilesResult(String location) {
- super(location);
- }
-
- /**
- * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
- * dispatch fails a 404 error will be sent back in the http response.
- *
- * @param location the location to dispatch to.
- * @param invocation the execution state of the action
- * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
- * HTTP request.
- */
- public void doExecute(String location, ActionInvocation invocation) throws Exception {
- setLocation(location);
-
- ServletContext servletContext = ServletActionContext.getServletContext();
-
- ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
- TilesContainer container = TilesAccess.getContainer(applicationContext);
-
- HttpServletRequest httpRequest = ServletActionContext.getRequest();
- HttpServletResponse httpResponse = ServletActionContext.getResponse();
-
- Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
-
- container.render(location, request);
- }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.struts2.views.tiles;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.result.ServletDispatcherResult;
+import org.apache.struts2.tiles.StrutsTilesAnnotationProcessor;
+import org.apache.struts2.tiles.annotation.TilesDefinition;
+import org.apache.tiles.Definition;
+import org.apache.tiles.TilesContainer;
+import org.apache.tiles.TilesException;
+
+import com.opensymphony.xwork2.ActionInvocation;
+import org.apache.tiles.access.TilesAccess;
+import org.apache.tiles.mgmt.MutableTilesContainer;
+import org.apache.tiles.request.ApplicationContext;
+import org.apache.tiles.request.Request;
+import org.apache.tiles.request.servlet.ServletRequest;
+import org.apache.tiles.request.servlet.ServletUtil;
+
+/**
+ * <!-- START SNIPPET: description -->
+ * Renders a view using struts-tiles.
+ * <!-- END SNIPPET: description -->
+ *
+ * <!-- START SNIPPET: webxml -->
+ * In your web.xml file, you need to add a TilesListener.
+ *
+ * <listener>
+ * <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
+ * </listener>
+ * <!-- END SNIPPET: webxml -->
+ *
+ * <!-- START SNIPPET: strutsxml -->
+ * In struts.xml, use type="tiles" on your <result>.
+ *
+ * <action name="editUser" class="userAction" method="edit">
+ * <result name="success" type="tiles">userForm</result>
+ * <result name="input" type="tiles">userList</result>
+ * </action>
+ * <!-- END SNIPPET: strutsxml -->
+ *
+ *
+ * <!-- START SNIPPET: packageconfig -->
+ *
+ * Making this result type the default for the current package.
+ *
+ * <result-types>
+ * <result-type name="tiles"
+ * class="org.apache.struts2.views.tiles.TilesResult" default="true" />
+ * </result-types>
+ * <!-- END SNIPPET: packageconfig -->
+ *
+ *
+ * <!-- START SNIPPET: tilesconfig -->
+ * You have to configure tiles itself. Therefore you can add <code>tiles.xml</code> either
+ * to resources or WEB-INF. You may also use annotations like {@link TilesDefinition}.
+ *
+ * <!-- END SNIPPET: tilesconfig -->
+ *
+ */
+public class TilesResult extends ServletDispatcherResult {
+
+ private static final long serialVersionUID = -3806939435493086244L;
+
+ private static final Logger LOG = LogManager.getLogger(TilesResult.class);
+
+ public TilesResult() {
+ super();
+ }
+
+ public TilesResult(String location) {
+ super(location);
+ }
+
+ /**
+ * Dispatches to the given location. Does its forward via a RequestDispatcher. If the
+ * dispatch fails a 404 error will be sent back in the http response.
+ *
+ * @param location the location to dispatch to.
+ * @param invocation the execution state of the action
+ * @throws Exception if an error occurs. If the dispatch fails the error will go back via the
+ * HTTP request.
+ */
+ public void doExecute(String location, ActionInvocation invocation) throws Exception {
+ StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
+ TilesDefinition tilesDefinition = null;
+ Object action = invocation.getAction();
+ String actionName = invocation.getInvocationContext().getName();
+
+ if (StringUtils.isEmpty(location)) {
+ // location not set -> action must have one @TilesDefinition
+ tilesDefinition = annotationProcessor.findAnnotation(action, null);
+ String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? tilesDefinition.name() : actionName;
+ location = tileName;
+ LOG.debug("using new location name '{}' and @TilesDefinition '{}'", location, tilesDefinition);
+ }
+ setLocation(location);
+
+ ServletContext servletContext = ServletActionContext.getServletContext();
+
+ ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
+ TilesContainer container = TilesAccess.getContainer(applicationContext);
+
+ HttpServletRequest httpRequest = ServletActionContext.getRequest();
+ HttpServletResponse httpResponse = ServletActionContext.getResponse();
+
+ Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
+
+ boolean definitionValid = false;
+ try {
+ LOG.debug("checking if tiles definition exists '{}'", location);
+ definitionValid = container.isValidDefinition(location, request);
+ } catch (TilesException e) {
+ LOG.warn("got TilesException while checking if definiton exists, ignoring it", e);
+ }
+ if (!definitionValid) {
+ if (tilesDefinition == null) {
+ // tilesDefinition not found yet, search in action
+ tilesDefinition = annotationProcessor.findAnnotation(action, location);
+ }
+ if (tilesDefinition != null) {
+ Definition definition = annotationProcessor.buildTilesDefinition(location, tilesDefinition);
+ if (container instanceof MutableTilesContainer) {
+ LOG.debug("registering tiles definition with name '{}'", definition.getName());
+ ((MutableTilesContainer)container).register(definition, request);
+ } else {
+ LOG.error("cannot register tiles definition as tiles container is not mutable!");
+ }
+ } else {
+ LOG.warn("could not find @TilesDefinition for action: {}", actionName);
+ }
+ }
+
+ container.render(location, request);
+ }
+}
[11/13] struts git commit: removed outcommented line
Posted by cn...@apache.org.
removed outcommented line
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f5ef1438
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f5ef1438
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f5ef1438
Branch: refs/heads/master
Commit: f5ef1438aaf4d9841dd5180a470dbe52edd8693e
Parents: 8651545
Author: cnenning <cn...@apache.org>
Authored: Mon Feb 1 09:45:34 2016 +0100
Committer: cnenning <cn...@apache.org>
Committed: Mon Feb 1 09:45:34 2016 +0100
----------------------------------------------------------------------
.../apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/f5ef1438/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
----------------------------------------------------------------------
diff --git a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
index acaacce..c71d100 100644
--- a/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
+++ b/plugins/tiles/src/test/java/org/apache/struts2/tiles/StrutsTilesAnnotationProcessorTest.java
@@ -109,7 +109,6 @@ public class StrutsTilesAnnotationProcessorTest {
Assert.assertNull(definition.getExtends());
Attribute templateAttribute = definition.getTemplateAttribute();
Assert.assertNull(templateAttribute.getValue());
- //Assert.assertNull(templateAttribute.getRenderer());
Assert.assertNull(templateAttribute.getRole());
Assert.assertNull(templateAttribute.getExpressionObject());