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:38 UTC
[03/13] struts git commit: added sample for tiles annotations
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>