Author: mrdon
Date: Sat Oct 20 08:24:33 2007
New Revision: 586743
URL: http://svn.apache.org/viewvc?rev=586743&view=rev
Log:
Adding showcase app for rest plugin
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/
struts/sandbox/trunk/struts2-rest-plugin/showcase/pom.xml
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/Order.java
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrderResource.java
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/struts.properties
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/web.xml
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/index.jsp
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-index.jsp
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-input.jsp
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-new.jsp
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-show.jsp
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-success.jsp
Added: struts/sandbox/trunk/struts2-rest-plugin/showcase/pom.xml
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/pom.xml?rev=586743&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-rest-plugin/showcase/pom.xml (added)
+++ struts/sandbox/trunk/struts2-rest-plugin/showcase/pom.xml Sat Oct 20
08:24:33 2007
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-apps</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-rest-showcase</artifactId>
+ <packaging>war</packaging>
+ <version>2.1.0-SNAPSHOT</version>
+ <name>Struts 2 Rest Showcase Example</name>
+ <description>Struts 2 Rest Showcase Example</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.struts</groupId>
+ <artifactId>struts2-rest-plugin</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+ <build>
+ <finalName>struts2-rest-showcase</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.0.1</version>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/Order.java
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/Order.java?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/Order.java
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/Order.java
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,42 @@
+package org.apache.struts2.rest.example;
+
+public class Order {
+ String id;
+ String clientName;
+ int amount;
+
+ public Order() {}
+
+ public Order(String id, String clientName, int amount) {
+ super();
+ this.id = id;
+ this.clientName = clientName;
+ this.amount = amount;
+ }
+ public int getAmount() {
+ return amount;
+ }
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+ public String getClientName() {
+ return clientName;
+ }
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ }
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void copyTo(Order order) {
+ order.setId(getId());
+ order.setAmount(getAmount());
+ order.setClientName(getClientName());
+ }
+
+
+}
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrderResource.java
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrderResource.java?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrderResource.java
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrderResource.java
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,75 @@
+package org.apache.struts2.rest.example;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.rest.DefaultRestInfo;
+import org.apache.struts2.rest.RestInfo;
+
+import com.opensymphony.xwork2.ModelDriven;
+
+public class OrderResource implements ModelDriven<Object>, ParameterAware{
+
+ private Order model = new Order();
+ private static Map<String,Order> orders = new HashMap<String,Order>() {{
+ put("3", new Order("3", "Bob", 33));
+ put("4", new Order("4", "Sarah", 44));
+ put("5", new Order("5", "Jim", 66));
+ }};
+ private Collection<Order> list;
+
+ public String show() {
+ return "show";
+ }
+
+ public String input() {
+ if (model.getId() != null) {
+ return "input";
+ } else {
+ return "new";
+ }
+
+ }
+
+ public String destroy() {
+ orders.remove(model.getId());
+ return "success";
+ }
+
+ public RestInfo create() {
+ orders.put(model.getId(), model);
+ return new DefaultRestInfo()
+ .setLocationId(model.getId())
+ .renderResult("success");
+ }
+
+ public String update() {
+ orders.put(model.getId(), model);
+ return "success";
+ }
+
+ public RestInfo index() {
+ list = orders.values();
+
+ return new DefaultRestInfo()
+ .renderResult("index")
+ .withETag("2323");
+ }
+
+ public Object getModel() {
+ return (list != null ? list : model);
+ }
+
+ // Silly workaround since modeldriven doesn't work right in xwork 2.1.0
+ public void setParameters(Map<String,String[]> parameters) {
+ if (parameters.get("id") != null &&
orders.get(parameters.get("id")[0]) != null) {
+ orders.get(parameters.get("id")[0]).copyTo(model);
+ }
+ }
+
+
+}
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/struts.properties
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/struts.properties?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/struts.properties
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/resources/struts.properties
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,4 @@
+
+struts.action.extension=,,xhtml,xml,json
+
+struts.devMode = true
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/web.xml?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/web.xml
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/WEB-INF/web.xml
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app id="starter" version="2.4"
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+
+ <display-name>Struts 2 Rest Example</display-name>
+
+
+ <!-- Filters -->
+ <filter>
+ <filter-name>action2</filter-name>
+
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
+ <init-param>
+ <param-name>actionPackages</param-name>
+ <param-value>org.apache.struts2.rest.example</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>action2</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <!-- Welcome file lists -->
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+</web-app>
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/index.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/index.jsp?rev=586743&view=auto
==============================================================================
--- struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/index.jsp
(added)
+++ struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/index.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,2 @@
+
+<% response.sendRedirect("order/.xhtml"); %>
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-index.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-index.jsp?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-index.jsp
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-index.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Orders</title>
+</head>
+<body>
+ <table>
+ <tr>
+ <th>ID</th>
+ <th>Client</th>
+ <th>Amount</th>
+ <th>Actions</th>
+ </tr>
+ <s:iterator value="model">
+ <tr>
+ <td><s:property value="id" /></td>
+ <td><s:property value="clientName" /></td>
+ <td><s:property value="amount" /></td>
+ <td><a href="<s:property value="id" />.xhtml">View</a> |
+ <a href="<s:property value="id" />;edit.xhtml">Edit</a> |
+ <a href="<s:property value="id"
/>.xhtml?_method=DELETE">Delete</a></td>
+ </tr>
+ </s:iterator>
+ </table>
+ <a href="new.xhtml">Create a new order</a>
+</body>
+</html>
+
\ No newline at end of file
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-input.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-input.jsp?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-input.jsp
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-input.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Order <s:property value="id" /></title>
+</head>
+<body>
+ <s:form method="post" action="%{id}.xhtml">
+ <s:hidden name="_method" value="put" />
+ <table>
+ <s:textfield name="id" label="ID" />
+ <s:textfield name="clientName" label="Client"/>
+ <s:textfield name="amount" label="Amount" />
+ <tr>
+ <td colspan="2">
+ <s:submit />
+ </td>
+ </table>
+ </s:form>
+ <a href="./.xhtml">Back to Orders</a>
+</body>
+</html>
+
\ No newline at end of file
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-new.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-new.jsp?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-new.jsp
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-new.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>New Order</title>
+</head>
+<body>
+ <s:form method="post" action="./.xhtml">
+ <table>
+ <s:textfield name="id" label="ID" />
+ <s:textfield name="clientName" label="Client"/>
+ <s:textfield name="amount" label="Amount" />
+ <tr>
+ <td colspan="2">
+ <s:submit />
+ </td>
+ </table>
+ </s:form>
+ <a href="./.xhtml">Back to Orders</a>
+</body>
+</html>
+
\ No newline at end of file
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-show.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-show.jsp?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-show.jsp
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-show.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Order <s:property value="model.id" /></title>
+</head>
+<body>
+ <table>
+ <tr>
+ <th>ID</th>
+ <td><s:property value="model.id" /></td>
+ </tr>
+ <tr>
+ <th>Client</th>
+ <td><s:property value="model.clientName" /></td>
+ </tr>
+ <tr>
+ <th>Amount</th>
+ <td><s:property value="model.amount" /></td>
+ </tr>
+ </table>
+ <a href="./.xhtml">Back to Orders</a>
+</body>
+</html>
+
\ No newline at end of file
Added:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-success.jsp
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-success.jsp?rev=586743&view=auto
==============================================================================
---
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-success.jsp
(added)
+++
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/order-success.jsp
Sat Oct 20 08:24:33 2007
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC
+ "-//W3C//DTD XHTML 1.1 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Operation Successful</title>
+</head>
+<body>
+ Operation Successful <br />
+ <a href="./.xhtml">Back to Orders</a>
+</body>
+</html>
+
\ No newline at end of file