1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts.tiles2.preparer;
23
24 import org.apache.struts.action.Action;
25 import org.apache.tiles.AttributeContext;
26 import org.apache.tiles.preparer.PreparerException;
27 import org.apache.tiles.preparer.ViewPreparer;
28 import org.apache.tiles.request.Request;
29 import org.apache.tiles.request.jakarta.servlet.ServletRequest;
30
31
32
33
34
35
36 public class ActionPreparer implements ViewPreparer {
37
38
39
40
41 private Action action = null;
42
43
44
45
46
47
48 public ActionPreparer(Action action) {
49 this.action = action;
50 }
51
52
53 public void execute(Request tilesContext,
54 AttributeContext attributeContext) throws PreparerException {
55 if (tilesContext instanceof ServletRequest) {
56 ServletRequest servletTilesContext =
57 (ServletRequest) tilesContext;
58 try {
59 this.action.execute(null, null, servletTilesContext.getRequest(),
60 servletTilesContext.getResponse());
61 } catch (Exception e) {
62 throw new PreparerException(
63 "The enclosed action threw an exception", e);
64 }
65 } else {
66 throw new PreparerException("Not using a ServletTilesRequestContext");
67 }
68 }
69 }