View Javadoc

1   /*
2    * $Id: RemoteCallUIBean.java 451544 2006-09-30 05:38:02Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.components;
19  
20  import javax.servlet.http.HttpServletRequest;
21  import javax.servlet.http.HttpServletResponse;
22  
23  import com.opensymphony.xwork2.util.ValueStack;
24  
25  /***
26   * RemoteCallUIBean is superclass for all components dealing with remote calls.
27   *
28   */
29  public abstract class RemoteCallUIBean extends ClosingUIBean {
30  
31      protected String href;
32      protected String errorText;
33      protected String showErrorTransportText;
34      protected String afterLoading;
35  
36      public RemoteCallUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
37          super(stack, request, response);
38      }
39  
40      public void evaluateExtraParams() {
41          super.evaluateExtraParams();
42  
43          if (href != null) {
44              addParameter("href", findString(href));
45          }
46  
47          if (showErrorTransportText != null) {
48              addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean.class));
49          }
50  
51          if (errorText != null) {
52              addParameter("errorText", findString(errorText));
53          }
54  
55          if (afterLoading != null) {
56              addParameter("afterLoading", findString(afterLoading));
57          }
58      }
59  
60      /***
61       * The theme to use for the element. <b>This tag will usually use the ajax theme.</b>
62       * @s.tagattribute required="false" type="String"
63       */
64      public void setTheme(String theme) {
65          super.setTheme(theme);
66      }
67  
68      /***
69       * The URL to call to obtain the content
70       * @s.tagattribute required="false" type="String"
71       */
72      public void setHref(String href) {
73          this.href = href;
74      }
75  
76      /***
77       * The text to display to the user if the is an error fetching the content
78       * @s.tagattribute required="false" type="String"
79       */
80      public void setErrorText(String errorText) {
81          this.errorText = errorText;
82      }
83  
84      /***
85       * when to show the error message as content when the URL had problems
86       * @s.tagattribute required="false" type="Boolean" default="false"
87       */
88      public void setShowErrorTransportText(String showErrorTransportText) {
89          this.showErrorTransportText = showErrorTransportText;
90      }
91  
92      /***
93       * Javascript code that will be executed after the content has been fetched
94       * @s.tagattribute required="false" type="String"
95       */
96      public void setAfterLoading(String afterLoading) {
97          this.afterLoading = afterLoading;
98      }
99  }