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 image.
024: * @author Joe Walker [joe at getahead dot org]
025: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026: */
027: public class Image 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 Image(Context context, String extension,
034: ScriptProxy scriptProxy) {
035: super (context, extension, scriptProxy);
036: }
037:
038: /**
039: *
040: */
041: @SuppressWarnings("unchecked")
042: public void getRenderedWidth(
043: org.directwebremoting.proxy.Callback<Integer> callback) {
044: ScriptBuffer script = new ScriptBuffer();
045: String callbackPrefix = "";
046:
047: if (callback != null) {
048: callbackPrefix = "var reply = ";
049: }
050:
051: script.appendCall(callbackPrefix + getContextPath()
052: + "getRenderedWidth");
053:
054: if (callback != null) {
055: String key = org.directwebremoting.extend.CallbackHelper
056: .saveCallback(callback, Integer.class);
057: script
058: .appendCall("__System.activateCallback", key,
059: "reply");
060: }
061:
062: getScriptProxy().addScript(script);
063: }
064:
065: /**
066: *
067: */
068: @SuppressWarnings("unchecked")
069: public void getRenderedHeight(
070: org.directwebremoting.proxy.Callback<Integer> callback) {
071: ScriptBuffer script = new ScriptBuffer();
072: String callbackPrefix = "";
073:
074: if (callback != null) {
075: callbackPrefix = "var reply = ";
076: }
077:
078: script.appendCall(callbackPrefix + getContextPath()
079: + "getRenderedHeight");
080:
081: if (callback != null) {
082: String key = org.directwebremoting.extend.CallbackHelper
083: .saveCallback(callback, Integer.class);
084: script
085: .appendCall("__System.activateCallback", key,
086: "reply");
087: }
088:
089: getScriptProxy().addScript(script);
090: }
091:
092: /**
093: * Returns the URI of this image.
094: */
095: @SuppressWarnings("unchecked")
096: public void getSrc(
097: org.directwebremoting.proxy.Callback<String> callback) {
098: ScriptBuffer script = new ScriptBuffer();
099: String callbackPrefix = "";
100:
101: if (callback != null) {
102: callbackPrefix = "var reply = ";
103: }
104:
105: script.appendCall(callbackPrefix + getContextPath() + "getSrc");
106:
107: if (callback != null) {
108: String key = org.directwebremoting.extend.CallbackHelper
109: .saveCallback(callback, String.class);
110: script
111: .appendCall("__System.activateCallback", key,
112: "reply");
113: }
114:
115: getScriptProxy().addScript(script);
116: }
117:
118: /**
119: * Sets the URI of this image. The URI can be absolute or relative from the content base of the server that
120: owns this object.
121: * @param srcSrc
122: * @return this object
123: */
124: public jsx3.gui.Image setSrc(String srcSrc) {
125: ScriptBuffer script = new ScriptBuffer();
126: script.appendCall(getContextPath() + "setSrc", srcSrc);
127: getScriptProxy().addScript(script);
128: return this;
129: }
130:
131: }
|