001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.core;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.gwtext.client.util.JavaScriptObjectHelper;
013:
014: /**
015: * {@link UpdateManager} configuration class.
016: *
017: * @see com.gwtext.client.core.UpdateManager#update(String, UrlLoadConfig , UrlLoadCallback, boolean)
018: */
019: public class UrlLoadConfig extends BaseConfig {
020:
021: /**
022: * The url for the request.
023: *
024: * @param url the request url
025: */
026: public void setUrl(String url) {
027: JavaScriptObjectHelper.setAttribute(jsObj, "url", url);
028: }
029:
030: /**
031: * The parameters to pass as a url encoded string "param1=1¶m2=2"
032: *
033: * @param params the request parameters
034: */
035: public void setParams(String params) {
036: JavaScriptObjectHelper.setAttribute(jsObj, "params", params);
037: }
038:
039: /**
040: * The parameters to pass.
041: *
042: * @param params the request params
043: */
044: public void setParams(UrlParam[] params) {
045: if (params != null && params.length > 0) {
046: JavaScriptObject paramObj = UrlParam.getJsObj(params);
047: JavaScriptObjectHelper.setAttribute(jsObj, "params",
048: paramObj);
049: }
050: }
051:
052: /**
053: * By default when you execute an update the defaultUrl is changed to the last used url. If true, it will not store the url.
054: *
055: * @param discardUrl true to discard url
056: */
057: public void setDiscardUrl(boolean discardUrl) {
058: JavaScriptObjectHelper.setAttribute(jsObj, "discardUrl",
059: discardUrl);
060: }
061:
062: /**
063: * Set the callback when the XHR call is complete.
064: *
065: * @param callback callback when transaction is complete
066: */
067: public native void setCallback(UrlLoadCallback callback)/*-{
068: var config = this.@com.gwtext.client.core.JsObject::getJsObj()();
069: config['callback'] = function(options, success, response) {
070: callback.@com.gwtext.client.core.UrlLoadCallback::execute(ZILjava/lang/String;)(success, response.status, response.responseText);
071: };
072: }-*/;
073:
074: /**
075: * @param nocache false to disable caching
076: */
077: public void setNocache(boolean nocache) {
078: JavaScriptObjectHelper.setAttribute(jsObj, "nocache", nocache);
079: }
080:
081: /**
082: * Loading text.
083: *
084: * @param text the loading text
085: */
086: public void setText(String text) {
087: JavaScriptObjectHelper.setAttribute(jsObj, "text", text);
088: }
089:
090: /**
091: * The request tiemout.
092: *
093: * @param timeout request timeout
094: */
095: public void setTimeout(int timeout) {
096: JavaScriptObjectHelper.setAttribute(jsObj, "timeout", timeout);
097: }
098:
099: /**
100: * Whether to execute scripts from the laoded content.
101: *
102: * @param scripts true to execute scripts
103: */
104: public void setScripts(boolean scripts) {
105: JavaScriptObjectHelper.setAttribute(jsObj, "scripts", scripts);
106: }
107: }
|