1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package examples.bean;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.apache.struts.action.Action;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31
32 /**
33 * Perform any tasks and setup any data that
34 * must be prepared before the form is displayed.
35 *
36 * @version $Rev: 471754 $ $Date: 2006-11-06 08:55:09 -0600 (Mon, 06 Nov 2006) $
37 */
38 public class PrepareBeanAction extends Action {
39
40
41
42 /**
43 * Constructor for PrepareBeanAction.
44 */
45 public PrepareBeanAction() {
46 super();
47 }
48
49
50
51 /**
52 * Process the request and return an <code>ActionForward</code> instance
53 * describing where and how control should be forwarded, or
54 * <code>null</code>if the response has already been completed.
55 *
56 * @param mapping The ActionMapping used to select this instance
57 * @param form The optional ActionForm bean for this request (if any)
58 * @param request The HTTP request we are processing
59 * @param response The HTTP response we are creating
60 *
61 * @exception Exception if an exception occurs
62 *
63 * @return the ActionForward to forward control to
64 */
65 public ActionForward execute(
66 ActionMapping mapping,
67 ActionForm form,
68 HttpServletRequest request,
69 HttpServletResponse response)
70 throws Exception {
71
72
73 ExampleBean example = new ExampleBean();
74 example.getList().add("List entry #1");
75 example.getList().add("List entry #2");
76 example.getList().add("List entry #3");
77 example.getList().add("List entry #4");
78
79
80 example.setNested(new NestedBean());
81
82
83 request.setAttribute("example", example);
84
85
86 return mapping.findForward("success");
87 }
88
89 }