Last modified by Ken McWilliams on 2012/03/10 01:50

From version Icon 2.1 Icon
edited by Ken McWilliams
on 2012/03/03 23:13
Change comment: There is no comment for this version
To version 1.1 Icon
edited by Ken McWilliams
on 2012/03/03 23:02
Change comment: There is no comment for this version

Summary

Details

Icon Page properties
Content
... ... @@ -52,30 +52,3 @@
52 52  To access this action: http:~/~/localhost:8080/Example/enter-name
53 53  
54 54  === Example 2 - Process form and display results ===
55 -
56 -We need to create an action to process the name from the above example. We know that we must put this action in a package which contains the name "action", "struts" or "struts2".
57 -
58 -**Create a package called**: com.example.action (really the package structure before ".action" can be what ever you want)
59 -
60 -**Create a file in this package called**: ProcessForm.java
61 -
62 -**Add the following source**:
63 -
64 -package com.example.action;
65 -\\import com.opensymphony.xwork2.ActionSupport;
66 -\\public class ProcessForm extends ActionSupport{
67 - private String name; ~/~/If this was public we could ommit the getters/setters
68 -\\ @Override
69 - public String execute(){
70 - ~/~/processing goes here
71 - ~/~/lets do something really simple like adding Hello to the name
72 - name = "Hello, " + name + "!";
73 - return SUCCESS;
74 - }
75 -\\ public String getName() {
76 - return name;
77 - }
78 -\\ public void setName(String name) {
79 - this.name = name;
80 - }
81 -}