1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts2.components;
19
20 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse;
22
23 import org.apache.struts2.views.annotations.StrutsTagAttribute;
24
25 import com.opensymphony.xwork2.util.ValueStack;
26
27 /***
28 * AbstractRemoteCallUIBean is superclass for all components dealing with remote
29 * calls.
30 */
31 /***
32 * TODO: Document AbstractRemoteCallUIBean.
33 *
34 * @author $Author: rgielen $
35 * @version $Revision: 630742 $ $Date: 2008-02-25 07:26:12 +0100 (Mo, 25 Feb 2008) $
36 */
37 public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements RemoteUICallBean {
38
39 protected String href;
40 protected String errorText;
41 protected String afterLoading;
42 protected String beforeLoading;
43 protected String executeScripts;
44 protected String loadingText;
45 protected String listenTopics;
46 protected String handler;
47 protected String formId;
48 protected String formFilter;
49 protected String notifyTopics;
50 protected String showErrorTransportText;
51 protected String indicator;
52 protected String showLoadingText;
53
54 public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request,
55 HttpServletResponse response) {
56 super(stack, request, response);
57 }
58
59 public void evaluateExtraParams() {
60 super.evaluateExtraParams();
61
62 if (href != null)
63 addParameter("href", ensureAttributeSafelyNotEscaped(findString(href)));
64 if (errorText != null)
65 addParameter("errorText", findString(errorText));
66 if (loadingText != null)
67 addParameter("loadingText", findString(loadingText));
68 if (afterLoading != null)
69 addParameter("afterLoading", findString(afterLoading));
70 if (beforeLoading != null)
71 addParameter("beforeLoading", findString(beforeLoading));
72 if (executeScripts != null)
73 addParameter("executeScripts", findValue(executeScripts, Boolean.class));
74 if (listenTopics != null)
75 addParameter("listenTopics", findValue(listenTopics, String.class));
76 if (notifyTopics != null)
77 addParameter("notifyTopics", findValue(notifyTopics, String.class));
78 if (handler != null)
79 addParameter("handler", findString(handler));
80 if (formId != null)
81 addParameter("formId", findString(formId));
82 if (formFilter != null)
83 addParameter("formFilter", findString(formFilter));
84 if (indicator != null)
85 addParameter("indicator", findString(indicator));
86 if (showErrorTransportText != null)
87 addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean.class));
88 else
89 addParameter("showErrorTransportText", true);
90 if (showLoadingText != null)
91 addParameter("showLoadingText", findString(showLoadingText));
92 }
93
94
95 @StrutsTagAttribute(description="Topic that will trigger the remote call")
96 public void setListenTopics(String listenTopics) {
97 this.listenTopics = listenTopics;
98 }
99
100 @StrutsTagAttribute(description="The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value.")
101 public void setHref(String href) {
102 this.href = href;
103 }
104
105
106 @StrutsTagAttribute(description="The text to display to the user if the is an error fetching the content")
107 public void setErrorText(String errorText) {
108 this.errorText = errorText;
109 }
110
111
112
113
114
115 public void setAfterLoading(String afterLoading) {
116 this.afterLoading = afterLoading;
117 }
118
119
120
121
122
123 public void setBeforeLoading(String beforeLoading) {
124 this.beforeLoading = beforeLoading;
125 }
126
127
128 @StrutsTagAttribute(description="Javascript code in the fetched content will be executed", type="Boolean", defaultValue="false")
129 public void setExecuteScripts(String executeScripts) {
130 this.executeScripts = executeScripts;
131 }
132
133 @StrutsTagAttribute(description="Text to be shown while content is being fetched", defaultValue="Loading...")
134 public void setLoadingText(String loadingText) {
135 this.loadingText = loadingText;
136 }
137
138
139 @StrutsTagAttribute(description="Javascript function name that will make the request")
140 public void setHandler(String handler) {
141 this.handler = handler;
142 }
143
144
145 @StrutsTagAttribute(description="Function name used to filter the fields of the form.")
146 public void setFormFilter(String formFilter) {
147 this.formFilter = formFilter;
148 }
149
150 @StrutsTagAttribute(description="Form id whose fields will be serialized and passed as parameters")
151 public void setFormId(String formId) {
152 this.formId = formId;
153 }
154
155 @StrutsTagAttribute(description="Topics that will published when the remote call completes")
156 public void setNotifyTopics(String notifyTopics) {
157 this.notifyTopics = notifyTopics;
158 }
159
160
161 @StrutsTagAttribute(description="Set whether errors will be shown or not", type="Boolean", defaultValue="true")
162 public void setShowErrorTransportText(String showError) {
163 this.showErrorTransportText = showError;
164 }
165
166 @StrutsTagAttribute(description="Id of element that will be shown while making request")
167 public void setIndicator(String indicator) {
168 this.indicator = indicator;
169 }
170
171 @StrutsTagAttribute(description="Show loading text on targets", type="Boolean", defaultValue="true")
172 public void setShowLoadingText(String showLoadingText) {
173 this.showLoadingText = showLoadingText;
174 }
175 }