diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName.java new file mode 100644 index 000000000..6fdabd030 --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName.java @@ -0,0 +1,23 @@ +package tutorial; + +import com.opensymphony.xwork2.ActionSupport; + +public class HelloName extends ActionSupport { + + public String execute() throws Exception { + if (getName() == null || getName().length() == 0) + return ERROR; + else + return SUCCESS; + } + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName2.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName2.java new file mode 100644 index 000000000..6466d26cd --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloName2.java @@ -0,0 +1,29 @@ +package tutorial; + +import com.opensymphony.xwork2.ActionSupport; +import org.apache.struts2.interceptor.ParameterAware; + +import java.util.Map; + +public class HelloName2 extends ActionSupport implements ParameterAware { + + public static String NAME = "name"; + + public String execute() { + String[] name = (String[]) parameters.get(NAME); + if (name == null || name[0] == null || name[0].length() == 0) + return ERROR; + else + return SUCCESS; + } + + Map parameters; + + public Map getParameters() { + return parameters; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } +} diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloWorld.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloWorld.java new file mode 100644 index 000000000..9af9b6728 --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/tutorial/HelloWorld.java @@ -0,0 +1,23 @@ +package tutorial; + +import com.opensymphony.xwork2.Action; + +import java.text.DateFormat; +import java.util.Date; + +public class HelloWorld implements Action { + + public String execute() { + message = "Hello, World!\n"; + message += "The time is:\n"; + message += DateFormat.getDateInstance().format(new Date()); + return SUCCESS; + } + + private String message; + + public String getMessage() { + return message; + } + +} \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/tutorial/HelloName-error.html b/apps/showcase/src/main/webapp/tutorial/HelloName-error.html new file mode 100644 index 000000000..7baf4ec75 --- /dev/null +++ b/apps/showcase/src/main/webapp/tutorial/HelloName-error.html @@ -0,0 +1,10 @@ + +
++Hmmm, you did not enter a name. Please try again! +
+ + diff --git a/apps/showcase/src/main/webapp/tutorial/HelloName-success.jsp b/apps/showcase/src/main/webapp/tutorial/HelloName-success.jsp new file mode 100644 index 000000000..ced01a313 --- /dev/null +++ b/apps/showcase/src/main/webapp/tutorial/HelloName-success.jsp @@ -0,0 +1,11 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + +
+ Hello,
What is your name?
+ + + + + diff --git a/apps/showcase/src/main/webapp/tutorial/HelloName2-success.jsp b/apps/showcase/src/main/webapp/tutorial/HelloName2-success.jsp new file mode 100644 index 000000000..02c357c85 --- /dev/null +++ b/apps/showcase/src/main/webapp/tutorial/HelloName2-success.jsp @@ -0,0 +1,12 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + +
+ Hello,
What is your name?
+ + + + + diff --git a/apps/showcase/src/main/webapp/tutorial/HelloWorld.jsp b/apps/showcase/src/main/webapp/tutorial/HelloWorld.jsp new file mode 100644 index 000000000..8943607af --- /dev/null +++ b/apps/showcase/src/main/webapp/tutorial/HelloWorld.jsp @@ -0,0 +1,11 @@ +<%@ taglib prefix="s" uri="/struts-tags" %> + + +Loading ...
+ + diff --git a/apps/showcase/src/test/java/org/apache/struts2/showcase/tutorial/HelloTest.java b/apps/showcase/src/test/java/org/apache/struts2/showcase/tutorial/HelloTest.java new file mode 100644 index 000000000..60debf518 --- /dev/null +++ b/apps/showcase/src/test/java/org/apache/struts2/showcase/tutorial/HelloTest.java @@ -0,0 +1,16 @@ +import junit.framework.TestCase; + +/** + * An example text class to verify the configuration. + */ +public class HelloTest extends TestCase { + + /** + * An example test that asserts true. + * + * @throws Exception On invalid assertions + */ + public void testHelloAction() throws Exception { + assertTrue(true); + } +}