|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.link; |
|
16 |
| |
|
17 |
| import java.util.List; |
|
18 |
| |
|
19 |
| import org.apache.tapestry.IActionListener; |
|
20 |
| import org.apache.tapestry.IDirect; |
|
21 |
| import org.apache.tapestry.IRequestCycle; |
|
22 |
| import org.apache.tapestry.Tapestry; |
|
23 |
| import org.apache.tapestry.engine.DirectServiceParameter; |
|
24 |
| import org.apache.tapestry.engine.IEngineService; |
|
25 |
| import org.apache.tapestry.engine.ILink; |
|
26 |
| import org.apache.tapestry.listener.ListenerInvoker; |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| public abstract class DirectLink extends AbstractLinkComponent implements IDirect |
|
37 |
| { |
|
38 |
| public abstract IActionListener getListener(); |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| public abstract boolean isStateful(); |
|
46 |
| |
|
47 |
75
| public ILink getLink(IRequestCycle cycle)
|
|
48 |
| { |
|
49 |
75
| Object[] serviceParameters = constructServiceParameters(getParameters());
|
|
50 |
| |
|
51 |
75
| DirectServiceParameter dsp = new DirectServiceParameter(this, serviceParameters);
|
|
52 |
| |
|
53 |
75
| return getDirectService().getLink(false, dsp);
|
|
54 |
| } |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
180
| public static Object[] constructServiceParameters(Object parameterValue)
|
|
73 |
| { |
|
74 |
180
| if (parameterValue == null)
|
|
75 |
141
| return null;
|
|
76 |
| |
|
77 |
39
| if (parameterValue instanceof Object[])
|
|
78 |
6
| return (Object[]) parameterValue;
|
|
79 |
| |
|
80 |
33
| if (parameterValue instanceof List)
|
|
81 |
| { |
|
82 |
24
| List list = (List) parameterValue;
|
|
83 |
| |
|
84 |
24
| return list.toArray();
|
|
85 |
| } |
|
86 |
| |
|
87 |
9
| return new Object[]
|
|
88 |
| { parameterValue }; |
|
89 |
| } |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
| |
|
99 |
69
| public void trigger(IRequestCycle cycle)
|
|
100 |
| { |
|
101 |
69
| IActionListener listener = getListener();
|
|
102 |
| |
|
103 |
69
| if (listener == null)
|
|
104 |
0
| throw Tapestry.createRequiredParameterException(this, "listener");
|
|
105 |
| |
|
106 |
69
| getListenerInvoker().invokeListener(listener, this, cycle);
|
|
107 |
| } |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
| public abstract Object getParameters(); |
|
112 |
| |
|
113 |
| |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| public abstract ListenerInvoker getListenerInvoker(); |
|
120 |
| |
|
121 |
| |
|
122 |
| |
|
123 |
| |
|
124 |
| |
|
125 |
| |
|
126 |
| public abstract IEngineService getDirectService(); |
|
127 |
| } |