001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package jsx3.gui;
017:
018: import org.directwebremoting.ScriptBuffer;
019: import org.directwebremoting.proxy.ScriptProxy;
020: import org.directwebremoting.proxy.io.Context;
021:
022: /**
023: * Renders an IFrame.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class IFrame extends jsx3.gui.Block {
028: /**
029: * All reverse ajax proxies need context to work from
030: * @param scriptProxy The place we are writing scripts to
031: * @param context The script that got us to where we are now
032: */
033: public IFrame(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: *
040: */
041: public static final int SCROLLYES = 1;
042:
043: /**
044: *
045: */
046: public static final int SCROLLNO = 2;
047:
048: /**
049: *
050: */
051: public static final int SCROLLAUTO = 3;
052:
053: /**
054: * Returns the native iframe object of this iframe. Depending on browser security settings and the URL of this
055: iframe, the native iframe object may not be available. In this case, this method returns null.
056: */
057: @SuppressWarnings("unchecked")
058: public void getIFrame(
059: org.directwebremoting.proxy.Callback<String> callback) {
060: ScriptBuffer script = new ScriptBuffer();
061: String callbackPrefix = "";
062:
063: if (callback != null) {
064: callbackPrefix = "var reply = ";
065: }
066:
067: script.appendCall(callbackPrefix + getContextPath()
068: + "getIFrame");
069:
070: if (callback != null) {
071: String key = org.directwebremoting.extend.CallbackHelper
072: .saveCallback(callback, String.class);
073: script
074: .appendCall("__System.activateCallback", key,
075: "reply");
076: }
077:
078: getScriptProxy().addScript(script);
079: }
080:
081: /**
082: * Returns the native document object of this iframe. Depending on browser security settings and the URL of this
083: iframe, the native document object may not be available. In this case, this method returns null.
084: */
085: @SuppressWarnings("unchecked")
086: public void getContentDocument(
087: org.directwebremoting.proxy.Callback<String> callback) {
088: ScriptBuffer script = new ScriptBuffer();
089: String callbackPrefix = "";
090:
091: if (callback != null) {
092: callbackPrefix = "var reply = ";
093: }
094:
095: script.appendCall(callbackPrefix + getContextPath()
096: + "getContentDocument");
097:
098: if (callback != null) {
099: String key = org.directwebremoting.extend.CallbackHelper
100: .saveCallback(callback, String.class);
101: script
102: .appendCall("__System.activateCallback", key,
103: "reply");
104: }
105:
106: getScriptProxy().addScript(script);
107: }
108:
109: /**
110: * Returns the URI of this iframe.
111: */
112: @SuppressWarnings("unchecked")
113: public void getSrc(
114: org.directwebremoting.proxy.Callback<String> callback) {
115: ScriptBuffer script = new ScriptBuffer();
116: String callbackPrefix = "";
117:
118: if (callback != null) {
119: callbackPrefix = "var reply = ";
120: }
121:
122: script.appendCall(callbackPrefix + getContextPath() + "getSrc");
123:
124: if (callback != null) {
125: String key = org.directwebremoting.extend.CallbackHelper
126: .saveCallback(callback, String.class);
127: script
128: .appendCall("__System.activateCallback", key,
129: "reply");
130: }
131:
132: getScriptProxy().addScript(script);
133: }
134:
135: /**
136: * Sets the URI of this iframe. The URI can be absolute or relative from the content base of the server that
137: owns this object. If this iframe is rendered on screen, its location is updated immediately.
138: * @param srcSrc
139: * @return this object.
140: */
141: public jsx3.gui.IFrame setSrc(String srcSrc) {
142: ScriptBuffer script = new ScriptBuffer();
143: script.appendCall(getContextPath() + "setSrc", srcSrc);
144: getScriptProxy().addScript(script);
145: return this ;
146: }
147:
148: /**
149: * Returns the scroll mode of this iframe.
150: */
151: @SuppressWarnings("unchecked")
152: public void getScrolling(
153: org.directwebremoting.proxy.Callback<Integer> callback) {
154: ScriptBuffer script = new ScriptBuffer();
155: String callbackPrefix = "";
156:
157: if (callback != null) {
158: callbackPrefix = "var reply = ";
159: }
160:
161: script.appendCall(callbackPrefix + getContextPath()
162: + "getScrolling");
163:
164: if (callback != null) {
165: String key = org.directwebremoting.extend.CallbackHelper
166: .saveCallback(callback, Integer.class);
167: script
168: .appendCall("__System.activateCallback", key,
169: "reply");
170: }
171:
172: getScriptProxy().addScript(script);
173: }
174:
175: /**
176: * Sets the scroll mode of this iframe.
177: * @param intScrolling one of <code>SCROLLYES</code>, <code>SCROLLNO</code>, or <code>SCROLLAUTO</code>.
178: * @return this object.
179: */
180: public jsx3.gui.IFrame setScrolling(int intScrolling) {
181: ScriptBuffer script = new ScriptBuffer();
182: script.appendCall(getContextPath() + "setScrolling",
183: intScrolling);
184: getScriptProxy().addScript(script);
185: return this;
186: }
187:
188: }
|