Author: husted Date: Mon Sep 4 12:00:33 2006 New Revision: 440152 URL: http://svn.apache.org/viewvc?view=rev&rev=440152 Log: WW-1340 Streamline and extend "blank" for use with tutorial.
Added: struts/struts2/trunk/apps/blank/src/main/java/example/ struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java (contents, props changed) - copied, changed from r439371, struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/example/HomeAction.java struts/struts2/trunk/apps/blank/src/main/webapp/example/ - copied from r439371, struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/pages/ struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp (with props) struts/struts2/trunk/apps/blank/src/test/java/example/ struts/struts2/trunk/apps/blank/src/test/java/example/WelcomeTest.java Removed: struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/example/ struts/struts2/trunk/apps/blank/src/main/webapp/WEB-INF/pages/ struts/struts2/trunk/apps/blank/src/main/webapp/example/home.jsp struts/struts2/trunk/apps/blank/src/test/java/org/apache/struts2/example/ Modified: struts/struts2/trunk/apps/blank/src/main/resources/struts.xml struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp Copied: struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java (from r439371, struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/example/HomeAction.java) URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java?view=diff&rev=440152&p1=struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/example/HomeAction.java&r1=439371&p2=struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java&r2=440152 ============================================================================== --- struts/struts2/trunk/apps/blank/src/main/java/org/apache/struts2/example/HomeAction.java (original) +++ struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java Mon Sep 4 12:00:33 2006 @@ -15,24 +15,43 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.struts2.example; +package example; import com.opensymphony.xwork2.ActionSupport; /** - * <code>HomeAction</code> + * <code>Set welcome message.</code> * */ -public class HomeAction extends ActionSupport { +public class Welcome extends ActionSupport { private static final long serialVersionUID = -3881551454078687096L; - /** - * A default implementation that does nothing an returns "success". - * - * @return [EMAIL PROTECTED] #SUCCESS} - */ + public static final String MESSAGE = "Struts is up and running ..."; + public String execute() throws Exception { + setMessage(MESSAGE); return SUCCESS; + } + + /** + * Field for Message property. + */ + private String message; + + /** + * Return Message property. + * @return Message property + */ + public String getMessage() { + return message; + } + + /** + * Set Message property. + * @param message Text to display on Welcome page. + */ + public void setMessage(String message){ + this.message = message; } } Propchange: struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/struts2/trunk/apps/blank/src/main/java/example/Welcome.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Modified: struts/struts2/trunk/apps/blank/src/main/resources/struts.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/resources/struts.xml?view=diff&rev=440152&r1=440151&r2=440152 ============================================================================== --- struts/struts2/trunk/apps/blank/src/main/resources/struts.xml (original) +++ struts/struts2/trunk/apps/blank/src/main/resources/struts.xml Mon Sep 4 12:00:33 2006 @@ -5,12 +5,10 @@ <struts> <include file="struts-default.xml"/> - <package name="default" extends="struts-default"> + <package name="example" extends="struts-default"> - <default-action-ref name="home" /> - - <action name="home" class="org.apache.struts2.example.HomeAction"> - <result>/WEB-INF/pages/home.jsp</result> + <action name="*" class="example.{1}"> + <result>/example/{1}.jsp</result> </action> <!-- Add your actions here --> Added: struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp?view=auto&rev=440152 ============================================================================== --- struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp (added) +++ struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp Mon Sep 4 12:00:33 2006 @@ -0,0 +1,10 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + +<html> + <head> + <title>Welcome</title> + </head> + <body> + <h2><s:property value="message" /></h2> + </body> +</html> Propchange: struts/struts2/trunk/apps/blank/src/main/webapp/example/Welcome.jsp ------------------------------------------------------------------------------ svn:eol-style = native Modified: struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp?view=diff&rev=440152&r1=440151&r2=440152 ============================================================================== --- struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp (original) +++ struts/struts2/trunk/apps/blank/src/main/webapp/index.jsp Mon Sep 4 12:00:33 2006 @@ -1 +1 @@ -<% response.sendRedirect(request.getContextPath() + "/home.action"); %> +<% response.sendRedirect(request.getContextPath() + "/Welcome.action"); %> Added: struts/struts2/trunk/apps/blank/src/test/java/example/WelcomeTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/blank/src/test/java/example/WelcomeTest.java?view=auto&rev=440152 ============================================================================== --- struts/struts2/trunk/apps/blank/src/test/java/example/WelcomeTest.java (added) +++ struts/struts2/trunk/apps/blank/src/test/java/example/WelcomeTest.java Mon Sep 4 12:00:33 2006 @@ -0,0 +1,36 @@ +/* + * $Id: WelcomeTest.java 418530 2006-07-01 23:58:13Z mrdon $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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 example; + +import junit.framework.TestCase; +import com.opensymphony.xwork2.Action; +import com.opensymphony.xwork2.ActionSupport; + +/** + * <code>WelcomeTest</code> + * + */ +public class WelcomeTest extends TestCase { + + public void testWelcome() throws Exception { + Action welcome = new Welcome(); + String result = welcome.execute(); + assertTrue(ActionSupport.SUCCESS.equals(result)); + assertTrue(welcome.equals(Welcome.MESSAGE)); + } +}