001: /*
002: * $Id: AbstractRemoteCallUIBean.java 508280 2007-02-16 02:07:56Z musachy $
003: *
004: * Copyright 2006 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018: package org.apache.struts2.components;
019:
020: import javax.servlet.http.HttpServletRequest;
021: import javax.servlet.http.HttpServletResponse;
022:
023: import org.apache.struts2.views.annotations.StrutsTagAttribute;
024:
025: import com.opensymphony.xwork2.util.ValueStack;
026:
027: /**
028: * AbstractRemoteCallUIBean is superclass for all components dealing with remote
029: * calls.
030: */
031: /**
032: * TODO: Document AbstractRemoteCallUIBean.
033: *
034: * @author $Author: musachy $
035: * @version $Revision: 508280 $ $Date: 2007-02-15 21:07:56 -0500 (Thu, 15 Feb 2007) $
036: */
037: public abstract class AbstractRemoteCallUIBean extends ClosingUIBean
038: implements RemoteUICallBean {
039:
040: protected String href;
041: protected String errorText;
042: protected String afterLoading;
043: protected String beforeLoading;
044: protected String executeScripts;
045: protected String loadingText;
046: protected String listenTopics;
047: protected String handler;
048: protected String formId;
049: protected String formFilter;
050: protected String notifyTopics;
051: protected String showErrorTransportText;
052: protected String indicator;
053: protected String showLoadingText;
054:
055: public AbstractRemoteCallUIBean(ValueStack stack,
056: HttpServletRequest request, HttpServletResponse response) {
057: super (stack, request, response);
058: }
059:
060: public void evaluateExtraParams() {
061: super .evaluateExtraParams();
062:
063: if (href != null)
064: addParameter("href", findString(href));
065: if (errorText != null)
066: addParameter("errorText", findString(errorText));
067: if (loadingText != null)
068: addParameter("loadingText", findString(loadingText));
069: if (afterLoading != null)
070: addParameter("afterLoading", findString(afterLoading));
071: if (beforeLoading != null)
072: addParameter("beforeLoading", findString(beforeLoading));
073: if (executeScripts != null)
074: addParameter("executeScripts", findValue(executeScripts,
075: Boolean.class));
076: if (listenTopics != null)
077: addParameter("listenTopics", findValue(listenTopics,
078: String.class));
079: if (notifyTopics != null)
080: addParameter("notifyTopics", findValue(notifyTopics,
081: String.class));
082: if (handler != null)
083: addParameter("handler", findString(handler));
084: if (formId != null)
085: addParameter("formId", findString(formId));
086: if (formFilter != null)
087: addParameter("formFilter", findString(formFilter));
088: if (indicator != null)
089: addParameter("indicator", findString(indicator));
090: if (showErrorTransportText != null)
091: addParameter("showErrorTransportText", findValue(
092: showErrorTransportText, Boolean.class));
093: else
094: addParameter("showErrorTransportText", true);
095: if (showLoadingText != null)
096: addParameter("showLoadingText", findString(showLoadingText));
097: }
098:
099: @StrutsTagAttribute(description="Topic that will trigger the remote call")
100: public void setListenTopics(String listenTopics) {
101: this .listenTopics = listenTopics;
102: }
103:
104: @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.")
105: public void setHref(String href) {
106: this .href = href;
107: }
108:
109: @StrutsTagAttribute(description="The text to display to the user if the is an error fetching the content")
110: public void setErrorText(String errorText) {
111: this .errorText = errorText;
112: }
113:
114: /* (non-Javadoc)
115: * @see org.apache.struts2.components.RemoteUICallBean#setAfterLoading(java.lang.String)
116: */
117: public void setAfterLoading(String afterLoading) {
118: this .afterLoading = afterLoading;
119: }
120:
121: /* (non-Javadoc)
122: * @see org.apache.struts2.components.RemoteUICallBean#setBeforeLoading(java.lang.String)
123: */
124: public void setBeforeLoading(String beforeLoading) {
125: this .beforeLoading = beforeLoading;
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: @StrutsTagAttribute(description="Javascript function name that will make the request")
139: public void setHandler(String handler) {
140: this .handler = handler;
141: }
142:
143: @StrutsTagAttribute(description="Function name used to filter the fields of the form.")
144: public void setFormFilter(String formFilter) {
145: this .formFilter = formFilter;
146: }
147:
148: @StrutsTagAttribute(description="Form id whose fields will be serialized and passed as parameters")
149: public void setFormId(String formId) {
150: this .formId = formId;
151: }
152:
153: @StrutsTagAttribute(description="Topics that will published when the remote call completes")
154: public void setNotifyTopics(String notifyTopics) {
155: this .notifyTopics = notifyTopics;
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: @StrutsTagAttribute(description="Show loading text on targets",type="Boolean",defaultValue="true")
169: public void setShowLoadingText(String showLoadingText) {
170: this.showLoadingText = showLoadingText;
171: }
172: }
|