Java Doc for AsyncCallback.java in  » Ajax » GWT » com » google » gwt » user » client » rpc » 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 » GWT » com.google.gwt.user.client.rpc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.google.gwt.user.client.rpc.AsyncCallback

AsyncCallback
public interface AsyncCallback (Code)
The primary interface a caller must implement to receive a response from a remote procedure call.

If an RPC is successful, then AsyncCallback.onSuccess(Object) is called, otherwise AsyncCallback.onFailure(Throwable) is called.

Each callable asynchronous method corresponds to a method in the correlated service interface. The asynchronous method always takes an AsyncCallback as its last parameter.

As an example, suppose the service interface defines a method called getShapes as follows:

 Shape[] getShapes(String databaseName) throws ShapeException, DbException;
 
Its asynchronous counterpart method be declared as:
 void getShapes(String databaseName, AsyncCallback callback);
 
Note that throws declaration is not repeated in the async version.

A call with a typical use of AsyncCallback might look like this:

 service.getShapes(dbName, new AsyncCallback() {
 public void onSuccess(Object result) {
 // It's always safe to downcast to the known return type. 
 Shape[] shapes = (Shape[]) result;
 controller.processShapes(shapes);
 }
 public void onFailure(Throwable caught) {
 // Convenient way to find out which exception was thrown.
 try {
 throw caught;
 } catch (IncompatibleRemoteServiceException e) {
 // this client is not compatible with the server; cleanup and refresh the 
 // browser
 } catch (InvocationException e) {
 // the call didn't complete cleanly
 } catch (ShapeException e) {
 // one of the 'throws' from the original method
 } catch (DbException e) {
 // one of the 'throws' from the original method
 } catch (Throwable e) {
 // last resort -- a very unexpected exception
 }
 }
 });
 

<
Parameters:
  T - >




Method Summary
 voidonFailure(Throwable caught)
     Called when an asynchronous call fails to complete normally.
 voidonSuccess(T result)
     Called when an asynchronous call completes successfully.



Method Detail
onFailure
void onFailure(Throwable caught)(Code)
Called when an asynchronous call fails to complete normally. IncompatibleRemoteServiceException s, InvocationException s, or checked exceptions thrown by the service method are examples of the type of failures that can be passed to this method.

If caught is an instance of an IncompatibleRemoteServiceException the application should try to get into a state where a browser refresh can be safely done.


Parameters:
  caught - failure encountered while executing a remote procedure call



onSuccess
void onSuccess(T result)(Code)
Called when an asynchronous call completes successfully. It is always safe to downcast the parameter (of type Object) to the return type of the original method for which this is a callback. Note that if the return type of the synchronous service interface method is a primitive then the parameter will be the boxed version of the primitive (for example, an int return type becomes an Integer .



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.