Source Code Cross Referenced for UpdateManager.java in  » Ajax » gwtext-2.01 » com » gwtext » client » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » gwtext 2.01 » com.gwtext.client.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.google.gwt.user.client.Element;
013:
014:        /**
015:         * Provides AJAX-style update for Element object.
016:         * <p/>
017:         * Usage :
018:         * <pre>
019:         * ExtElement el = Ext.get("foo");
020:         * UpdateManager mgr = el.getUpdateManager();
021:         * mgr.update("http://myserver.com/index.php", "param1=1&param2=2");
022:         * <p/>
023:         * mgr.formUpdate("myFormId", "http://myserver.com/index.php");
024:         * <p/>
025:         * // or directly (returns the same UpdateManager instance)
026:         * UpdateManager mgr2 = new UpdateManager("myElementId");
027:         * mgr2.startAutoRefresh(60, "http://myserver.com/index.php");
028:         * mgr2.addListener("update", new EventCallback() {
029:         *     public void execute(EventObject e) {
030:         *         //
031:         *     }
032:         * });
033:         *  </pre>
034:         */
035:        public class UpdateManager extends JsObject {
036:
037:            /**
038:             * Create new UpdateManager directly.
039:             *
040:             * @param elementID the elemetn ID
041:             */
042:            public UpdateManager(String elementID) {
043:                jsObj = create(elementID);
044:            }
045:
046:            /**
047:             * Create new UpdateManager directly.
048:             *
049:             * @param element the element
050:             */
051:            public UpdateManager(Element element) {
052:                jsObj = create(element);
053:            }
054:
055:            /**
056:             * Create new UpdateManager directly.
057:             *
058:             * @param element the element
059:             */
060:            public UpdateManager(ExtElement element) {
061:                jsObj = create(element.getJsObj());
062:            }
063:
064:            private native JavaScriptObject create(String elementID) /*-{
065:                   return new $wnd.Ext.UpdateManager(elementID);
066:               }-*/;
067:
068:            private native JavaScriptObject create(Element element) /*-{
069:                   return new $wnd.Ext.UpdateManager(element);
070:               }-*/;
071:
072:            private native JavaScriptObject create(JavaScriptObject element) /*-{
073:                   return new $wnd.Ext.UpdateManager(element);
074:               }-*/;
075:
076:            public UpdateManager(JavaScriptObject jsObj) {
077:                super (jsObj);
078:            }
079:
080:            public static UpdateManager instance(JavaScriptObject jsObj) {
081:                return new UpdateManager(jsObj);
082:            }
083:
084:            /**
085:             * Timeout for requests or form posts in seconds (Defaults to 30 seconds).
086:             *
087:             * @param timeout the default timeout
088:             */
089:            public static native void setDefaultTimeout(int timeout)/*-{
090:                    $wnd.Ext.UpdateManager.defaults.timeout = timeout;
091:                }-*/;
092:
093:            /**
094:             * True to process scripts in the output (Defaults to false).
095:             *
096:             * @param loadScripts true to laod scripts
097:             */
098:            public static native void setDefaultLoadScripts(boolean loadScripts)/*-{
099:                    $wnd.Ext.UpdateManager.defaults.loadScripts = loadScripts;
100:                }-*/;
101:
102:            /**
103:             * Blank page URL to use with SSL file uploads (Defaults to "about:blank").
104:             *
105:             * @param sslBlankUrl ssl blank url
106:             */
107:            public static native void setDefaultSslBlankUrl(String sslBlankUrl)/*-{
108:                    $wnd.Ext.UpdateManager.defaults.sslBlankUrl = sslBlankUrl;
109:                }-*/;
110:
111:            /**
112:             * Whether to append unique parameter on get request to disable caching (Defaults to false).
113:             *
114:             * @param disableCaching true to disable caching
115:             */
116:            public static native void setDefaultDisableCaching(
117:                    boolean disableCaching)/*-{
118:                    $wnd.Ext.UpdateManager.defaults.disableCaching = disableCaching;
119:                }-*/;
120:
121:            /**
122:             * Whether to show indicatorText when loading (Defaults to true).
123:             *
124:             * @param showLoadIndicator true to show indicator
125:             */
126:            public static native void setDefaultShowLoadIndicator(
127:                    boolean showLoadIndicator)/*-{
128:                    $wnd.Ext.UpdateManager.defaults.showLoadIndicator = showLoadIndicator;    
129:                }-*/;
130:
131:            /**
132:             * Text for loading indicator (Defaults to  '&lt;div class="loading-indicator"&gt;Loading...&lt;/div&gt;').
133:             *
134:             * @param indicatorText the indicator text
135:             */
136:            public static native void setDefaultIndicatorText(
137:                    String indicatorText)/*-{
138:                    $wnd.Ext.UpdateManager.defaults.indicatorText = indicatorText;
139:                }-*/;
140:
141:            /**
142:             * Aborts the executing transaction.
143:             */
144:            public native void abort() /*-{
145:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
146:                   um.abort();
147:               }-*/;
148:
149:            /**
150:             * Appends an event handler.
151:             *
152:             * @param eventName the type of event to append
153:             * @param cb        the event callback
154:             */
155:            public native void addListener(String eventName, EventCallback cb) /*-{
156:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
157:                   um.addListener(eventName, function(event) {
158:                           var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
159:                           cb.@com.gwtext.client.core.EventCallback::execute(Lcom/gwtext/client/core/EventObject;)(e);
160:                       }
161:                   );
162:               }-*/;
163:
164:            /**
165:             * Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipart/form-data", it assumes it's a file upload.
166:             * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.
167:             *
168:             * @param formID the form ID
169:             */
170:            public native void formUpdate(String formID) /*-{
171:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
172:                   um.formUpdate(formID);
173:               }-*/;
174:
175:            /**
176:             * Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipart/form-data", it assumes it's a file upload.
177:             * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.
178:             *
179:             * @param formID the form ID
180:             * @param url    The url to pass the form to. If omitted the action attribute on the form will be used.
181:             */
182:            public native void formUpdate(String formID, String url) /*-{
183:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
184:                   um.formUpdate(formID, url);
185:               }-*/;
186:
187:            /**
188:             * Performs an async form post, updating this element with the response. If the form has the attribute enctype="multipart/form-data", it assumes it's a file upload.
189:             * Uses this.sslBlankUrl for SSL file uploads to prevent IE security warning.
190:             *
191:             * @param formID   the form ID
192:             * @param url      The url to pass the form to. If omitted the action attribute on the form will be used.
193:             * @param reset    Whether to try to reset the form after the update
194:             * @param callback callback when transaction is complete
195:             */
196:            public native void formUpdate(String formID, String url,
197:                    boolean reset, UrlLoadCallback callback) /*-{
198:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
199:                   var cb;
200:                   if(callback != null) {
201:                       cb = function(options, success, response) {
202:                           callback.@com.gwtext.client.core.UrlLoadCallback::execute(ZILjava/lang/String;)(success, response.status, response.responseText);
203:                       }
204:                   }
205:                   um.formUpdate(formID, url, reset, cb);
206:               }-*/;
207:
208:            /**
209:             * Get the Element this UpdateManager is bound to.
210:             *
211:             * @return the element
212:             */
213:            public native ExtElement getEl() /*-{
214:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
215:                   var el = um.getEl();
216:                   return @com.gwtext.client.core.ExtElement::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(el);
217:               }-*/;
218:
219:            /**
220:             * Returns true if an update is in progress.
221:             *
222:             * @return true if update in progress
223:             */
224:            public native boolean isUpdating() /*-{
225:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
226:                   return um.isUpdating();
227:               }-*/;
228:
229:            /**
230:             * Refresh the element with the last used url or defaultUrl. If there is no url, it returns immediately.
231:             */
232:            public native void refresh() /*-{
233:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
234:                   um.refresh();
235:               }-*/;
236:
237:            /**
238:             * Set the defaultUrl used for updates.
239:             *
240:             * @param url the default url
241:             */
242:            public native void setDefaultUrl(String url) /*-{
243:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
244:                   um.setDefaultUrl(url);
245:               }-*/;
246:
247:            /**
248:             * True to disable caching.
249:             *
250:             * @param disableCaching true to disable caching
251:             */
252:            public native void setDisableCaching(boolean disableCaching) /*-{
253:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
254:                   um.disableCaching = disableCaching;
255:               }-*/;
256:
257:            /**
258:             * Set the loading indicator text.
259:             *
260:             * @param indicatorText the indicator text
261:             */
262:            public native void setIndicatorText(String indicatorText) /*-{
263:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
264:                   um.indicatorText = indicatorText;
265:               }-*/;
266:
267:            /**
268:             * Wheter to load scripts in the contents.
269:             *
270:             * @param loadScripts true to laod scripts
271:             */
272:            public native void setLoadScripts(boolean loadScripts) /*-{
273:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
274:                   um.loadScripts = loadScripts;
275:               }-*/;
276:
277:            //TODO this does not work in Ext (possible Ext bug).
278:            /**
279:             * Request method (GET or POST).
280:             *
281:             * @param method the request method
282:             */
283:            public native void setMethod(Connection.Method method) /*-{
284:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
285:                   um.method = method.@com.gwtext.client.core.Connection$Method::getMethod()();
286:               }-*/;
287:
288:            /**
289:             * Whether to show the loading indicator.
290:             *
291:             * @param showIndicator true to show loading indicator
292:             */
293:            public native void setShowIndicator(boolean showIndicator) /*-{
294:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
295:                   um.showIndicator = showIndicator;
296:               }-*/;
297:
298:            /**
299:             * Timeout for the request.
300:             *
301:             * @param timeout the timeout in seconds
302:             */
303:            public native void setTimeout(int timeout) /*-{
304:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
305:                   um.timeout = timeout ;
306:               }-*/;
307:
308:            /**
309:             * Set this element to auto refresh.
310:             *
311:             * @param interval how often to update in seconds
312:             */
313:            public native void startAutoRefresh(int interval) /*-{
314:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
315:                   um.startAutoRefresh(interval);
316:               }-*/;
317:
318:            /**
319:             * Set this element to auto refresh.
320:             *
321:             * @param interval how often to update in seconds
322:             * @param url      The url for this request or a function to call to get the url (Defaults to the last used url)
323:             */
324:            public native void startAutoRefresh(int interval, String url) /*-{
325:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
326:                   um.startAutoRefresh(interval, url);
327:               }-*/;
328:
329:            /**
330:             * Set this element to auto refresh.
331:             *
332:             * @param interval   how often to update in seconds
333:             * @param url        The url for this request or a function to call to get the url (Defaults to the last used url)
334:             * @param params     the parameters to pass as a url encoded string "&param1=1&param2=2"
335:             * @param cb         callback when the transaction is complete
336:             * @param refreshNow whether to execute the refresh now, or wait the interval
337:             */
338:            public native void startAutoRefresh(int interval, String url,
339:                    String params, Function cb, boolean refreshNow) /*-{
340:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
341:                   um.startAutoRefresh(interval, url, params, function() {
342:                       cb.@com.gwtext.client.core.Function::execute()();
343:                   }, refreshNow);
344:               }-*/;
345:
346:            /**
347:             * Stop auto refresh on this element.
348:             */
349:            public native void stopAutoRefresh() /*-{
350:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
351:                   um.stopAutoRefresh();
352:               }-*/;
353:
354:            /**
355:             * Performs an async request, updating this element with the response. If params are specified it uses POST,
356:             * otherwise it uses GET.
357:             *
358:             * @param url    the url for this request
359:             * @param params the parameters to pass as a url encoded string "param1=1&param2=2"
360:             */
361:            public native void update(String url, String params) /*-{
362:                   var um = this.@com.gwtext.client.core.JsObject::getJsObj()();
363:                   um.update(url, params);
364:               }-*/;
365:
366:            /**
367:             * Performs an async request, updating this element with the response. If params are specified it uses POST,
368:             * otherwise it uses GET.
369:             *
370:             * @param url        the url for this request
371:             * @param params     the parameters to pass as a url encoded string "param1=1&param2=2"
372:             * @param callback   the callback when transaction is complete
373:             * @param discardUrl by default when you execute an update the defaultUrl is changed to the last used url. If true, it will not store the url.
374:             */
375:            public void update(String url, UrlLoadConfig params,
376:                    UrlLoadCallback callback, boolean discardUrl) {
377:                if (params == null) {
378:                    params = new UrlLoadConfig();
379:                }
380:                params.setUrl(url);
381:                update(jsObj, params.getJsObj(), callback, discardUrl);
382:            }
383:
384:            private static native void update(JavaScriptObject updateManager,
385:                    JavaScriptObject params, UrlLoadCallback callback,
386:                    boolean discardUrl)/*-{
387:                    var cb;
388:                    if(callback != null) {
389:                        cb = function(options, success, response) {
390:                            callback.@com.gwtext.client.core.UrlLoadCallback::execute(ZILjava/lang/String;)(success, response.status, response.responseText);
391:                        }
392:                    }
393:                    updateManager.update(params, null, cb, discardUrl);
394:                }-*/;
395:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.