com.smartgwt.client.docs
Interface NonJavaBackend


public interface NonJavaBackend

.NET, PHP, Serverless Integration

Smart GWT is fully functional without installation of the Java server included in the SDK, and can be integrated with any server technology. This topic provides pointers to documentation that is most relevant for this type of integration.

Installation

As described in 'Deploying Smart GWT', for a client-only integration, installation consists of just copying a directory of JavaScript and media files to your webserver.

Creating Components

Smart GWT components can be included in any .html page, including dynamically generated pages produced by .php or .asp files. The Smart GWT libraries can be included in the page as follows:

 <HTML><HEAD>
 <SCRIPT>var isomorphicDir="../isomorphic/";</SCRIPT>

 <SCRIPT SRC=../isomorphic/system/modules/ISC_Core.js></SCRIPT>
 <SCRIPT
 SRC=../isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
 <SCRIPT
 SRC=../isomorphic/system/modules/ISC_Containers.js></SCRIPT>
 <SCRIPT
 SRC=../isomorphic/system/modules/ISC_Grids.js></SCRIPT>
 <SCRIPT
 SRC=../isomorphic/system/modules/ISC_Forms.js></SCRIPT>
 <SCRIPT
 SRC=../isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
 <SCRIPT SRC=../isomorphic/skins/Smart
 GWT/load_skin.js></SCRIPT>
 </HEAD><BODY>
 ...
Smart GWT components can then be created via normal JavaScript:
 <SCRIPT>
 isc.Button.create({
     title:"Button",
    
 click:"isc.say('Hello World')"
 });
 </SCRIPT>
This approach is discussed in more detail in the QuickStart Guide, Chapter 4, Coding. Note that JavaScript-based component instantiation is currently the recommended approach, and most examples are provided in the JavaScript format.

Data Loading / Data Binding

The primary focus of Smart GWT integration is connecting DataSource operations to your server. The 'Client-side Data Integration' chapter covers the key approaches, including cookbook approaches for REST-based integration with any server that can return XML or JSON over HTTP.

Simple RPCs (non-DataSource requests)

You can implement simple RPCs as web service operations: use XMLTools.loadWSDL(java.lang.String, com.smartgwt.client.data.WSDLLoadCallback) to load the service definition, and then use WebService.callOperation(java.lang.String, java.util.Map, java.lang.String, com.smartgwt.client.data.WebServiceCallback) to call the operations. Note that some server frameworks allow the generation of WSDL from server method signatures.

Alternatively, if your backend is capable of outputting JSON (JavaScript Object Notation), you can use evalResult to directly turn JSON results into live JavaScript objects. serverOutputAsString lets you load arbitrary server results, including JSON results that need to be processed before they can be eval()'d.

HTTPProxy: Cross-site or cross-port data loading

If you develop a prototype using the Smart GWT SDK and Smart GWT Java Server, and then you migrate the prototype to another server technology, you need to be aware that the Smart GWT Java Server includes an HTTPProxy servlet that allows Smart GWT interfaces to contact servers other than the origin server (bypassing what is called the "same origin policy").

Smart GWT uses the HttpProxy automatically when needed, so it may not be obvious that the HTTPProxy is in use. Then, your migrated application will encounter errors attempting to contact the HTTPProxy servlet.

To avoid these errors, ensure that all services that your application uses are accessed using the same hostname and port as the page was loaded from. In particular, watch for WSDL files, which contain the service URL - you may need to use WebService.setLocation(java.lang.String) to ensure that the web service URL and page URL match.

If your production application really does need to access services or content hosted on other servers, typical practice is to pursue normal Smart GWT integration with your server, then write server-side code that contacts other hosts on behalf of your Smart GWT interface.