You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2007/10/28 01:52:11 UTC
svn commit: r589244 - in /struts/sandbox/trunk/struts2-rest-plugin:
showcase/src/main/java/org/apache/struts2/rest/example/
showcase/src/main/webapp/ src/main/resources/
Author: mrdon
Date: Sat Oct 27 16:52:09 2007
New Revision: 589244
URL: http://svn.apache.org/viewvc?rev=589244&view=rev
Log:
Adding automatic message storing across redirect default, using
action messages across redirect to give feedback operation was
successful
Removed:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-success.jsp
Modified:
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrdersController.java
struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-index.jsp
struts/sandbox/trunk/struts2-rest-plugin/src/main/resources/struts-plugin.xml
Modified: struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrdersController.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrdersController.java?rev=589244&r1=589243&r2=589244&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrdersController.java (original)
+++ struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/java/org/apache/struts2/rest/example/OrdersController.java Sat Oct 27 16:52:09 2007
@@ -6,6 +6,9 @@
import java.util.List;
import java.util.Map;
+import org.apache.struts2.config.Result;
+import org.apache.struts2.config.Results;
+import org.apache.struts2.dispatcher.ServletActionRedirectResult;
import org.apache.struts2.interceptor.ParameterAware;
import org.apache.struts2.rest.DefaultHttpHeaders;
import org.apache.struts2.rest.HttpHeaders;
@@ -14,6 +17,9 @@
import com.opensymphony.xwork2.Validateable;
import com.opensymphony.xwork2.ValidationAwareSupport;
+@Results({
+ @Result(name="success", type=ServletActionRedirectResult.class, value="orders")
+})
public class OrdersController extends ValidationAwareSupport implements ModelDriven<Object>, ParameterAware, Validateable{
private Order model = new Order();
@@ -46,11 +52,13 @@
public String destroy() {
orders.remove(model.getId());
+ addActionMessage("Order removed successfully");
return "success";
}
public HttpHeaders create() {
orders.put(model.getId(), model);
+ addActionMessage("New order created successfully");
return new DefaultHttpHeaders()
.setLocationId(model.getId())
.renderResult("success");
@@ -58,6 +66,7 @@
public String update() {
orders.put(model.getId(), model);
+ addActionMessage("Order updated successfully");
return "success";
}
@@ -66,7 +75,7 @@
return new DefaultHttpHeaders()
.renderResult("index")
- .withETag("2323");
+ .disableCaching();
}
public Object getModel() {
Modified: struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-index.jsp
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-index.jsp?rev=589244&r1=589243&r2=589244&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-index.jsp (original)
+++ struts/sandbox/trunk/struts2-rest-plugin/showcase/src/main/webapp/orders-index.jsp Sat Oct 27 16:52:09 2007
@@ -9,6 +9,7 @@
<title>Orders</title>
</head>
<body>
+ <s:actionmessage />
<table>
<tr>
<th>ID</th>
Modified: struts/sandbox/trunk/struts2-rest-plugin/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-rest-plugin/src/main/resources/struts-plugin.xml?rev=589244&r1=589243&r2=589244&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-rest-plugin/src/main/resources/struts-plugin.xml (original)
+++ struts/sandbox/trunk/struts2-rest-plugin/src/main/resources/struts-plugin.xml Sat Oct 27 16:52:09 2007
@@ -28,6 +28,7 @@
<interceptors>
<interceptor name="rest" class="org.apache.struts2.rest.ContentTypeInterceptor"/>
<interceptor name="restWorkflow" class="org.apache.struts2.rest.RestWorkflowInterceptor"/>
+ <interceptor name="messages" class="org.apache.struts2.interceptor.MessageStoreInterceptor" />
<!-- A complete stack with all the common interceptors in place.
Generally, this stack should be the one you use, though it
@@ -44,6 +45,9 @@
<interceptor-ref name="exception"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="servletConfig"/>
+ <interceptor-ref name="messages">
+ <param name="operationMode">AUTOMATIC</param>
+ </interceptor-ref>
<interceptor-ref name="prepare"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="chain"/>