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: 497654 $ $Date: 2007-01-18 19:21:57 -0500 (Thu, 18 Jan 2007) $
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
53 public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request,
54 HttpServletResponse response) {
55 super(stack, request, response);
56 }
57
58 public void evaluateExtraParams() {
59 super.evaluateExtraParams();
60
61 if (href != null)
62 addParameter("href", findString(href));
63 if (errorText != null)
64 addParameter("errorText", findString(errorText));
65 if (loadingText != null)
66 addParameter("loadingText", findString(loadingText));
67 if (afterLoading != null)
68 addParameter("afterLoading", findString(afterLoading));
69 if (beforeLoading != null)
70 addParameter("beforeLoading", findString(beforeLoading));
71 if (executeScripts != null)
72 addParameter("executeScripts", findValue(executeScripts, Boolean.class));
73 if (listenTopics != null)
74 addParameter("listenTopics", findValue(listenTopics, String.class));
75 if (notifyTopics != null)
76 addParameter("notifyTopics", findValue(notifyTopics, String.class));
77 if (handler != null)
78 addParameter("handler", findString(handler));
79 if (formId != null)
80 addParameter("formId", findString(formId));
81 if (formFilter != null)
82 addParameter("formFilter", findString(formFilter));
83 if (indicator != null)
84 addParameter("indicator", findString(indicator));
85 if (showErrorTransportText != null)
86 addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean.class));
87 else
88 addParameter("showErrorTransportText", true);
89 }
90
91
92 @StrutsTagAttribute(description="Topic that will trigger the remote call")
93 public void setListenTopics(String listenTopics) {
94 this.listenTopics = listenTopics;
95 }
96
97 @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.")
98 public void setHref(String href) {
99 this.href = href;
100 }
101
102
103 @StrutsTagAttribute(description="The text to display to the user if the is an error fetching the content")
104 public void setErrorText(String errorText) {
105 this.errorText = errorText;
106 }
107
108
109
110
111
112 public void setAfterLoading(String afterLoading) {
113 this.afterLoading = afterLoading;
114 }
115
116
117
118
119
120 public void setBeforeLoading(String beforeLoading) {
121 this.beforeLoading = beforeLoading;
122 }
123
124
125 @StrutsTagAttribute(description="Javascript code in the fetched content will be executed", type="Boolean", defaultValue="false")
126 public void setExecuteScripts(String executeScripts) {
127 this.executeScripts = executeScripts;
128 }
129
130 @StrutsTagAttribute(description="Text to be shown while content is being fetched", defaultValue="Loading...")
131 public void setLoadingText(String loadingText) {
132 this.loadingText = loadingText;
133 }
134
135
136 @StrutsTagAttribute(description="Javascript function name that will make the request")
137 public void setHandler(String handler) {
138 this.handler = handler;
139 }
140
141
142 @StrutsTagAttribute(description="Function name used to filter the fields of the form.")
143 public void setFormFilter(String formFilter) {
144 this.formFilter = formFilter;
145 }
146
147 @StrutsTagAttribute(description="Form id whose fields will be serialized and passed as parameters")
148 public void setFormId(String formId) {
149 this.formId = formId;
150 }
151
152 @StrutsTagAttribute(description="Topics that will published when the remote call completes")
153 public void setNotifyTopics(String notifyTopics) {
154 this.notifyTopics = notifyTopics;
155 }
156
157
158 @StrutsTagAttribute(description="Set whether errors will be shown or not", type="Boolean", defaultValue="true")
159 public void setShowErrorTransportText(String showError) {
160 this.showErrorTransportText = showError;
161 }
162
163 @StrutsTagAttribute(description="Id of element that will be shown while making request")
164 public void setIndicator(String indicator) {
165 this.indicator = indicator;
166 }
167
168 }