📄 rpcmanager.js
字号:
//> @attr RPCRequest.useSimpleHttp (boolean : false : IRWA)//// When set to true, assume the request is not going to the SmartClient server, and hence send// a simple HTTP request that does not use SmartClient-specific request encoding.// <P>// Values specified in +link{attr:RPCRequest.params} are sent to to the server as HTTP request// parameters. If +link{httpMethod} is "GET", parameters appear in the request URL, otherwise// if httpMethod is "POST", parameters are encoded in the request body (exactly like an HTML form// does). These parameters are then accessible via typical server-side APIs for retrieving// HTTP parameters, eg, servletRequest.getParameter(paramName) in Java Servlets. // <P>// Note that if +link{httpMethod} method is POST and +link{rpcRequest.data} is supplied,// +link{rpcRequest.data} is assumed to be a string to post as the HTTP request body, and// +link{rpcRequest.params} are sent as URL parameters instead. This usage is for sending// custom request bodies such as the XML payloads used for SOAP. In this case,// +link{rpcRequest.contentType} is typically also set to indicate the content type of the// request body.// <p>// Setting <code>useSimpleHttp</code> to true also automatically sets// +link{RPCRequest.serverOutputAsString} to true as well.//// @visibility external//<//> @attr RPCRequest.bypassCache (boolean : false : IRWA)//// For xmlHttp transport + httpMethod: "GET" only, set to true to force IE to send a conditional// GET request even if the browser thinks it has a current cached response.//// @visibility external//<// ---------------------------------------------------------------------------------------//> @type RPCCallback// A +link{type:Callback} to evaluate when an RPCRequest completes.// <p>// Parameters passed to this callback are:// <ul>// <li>rpcResponse: an +link{class:RPCResponse} encapsulating the server response to your// request// <li>data: just the "data" property from the RPCResponse, for convenience// <li>rpcRequest: the +link{class:RPCRequest} that was sent. You can use// +link{attr:rpcRequest.clientContext} to track state during the server turnaround.// </ul>// For example, to take the data returned by the server and display it in a previously created// ListGrid with the ID "myGrid":// <pre>// isc.RPCManager.send("getData", "myGrid.setData(data)");// </pre>// Or// <pre>// isc.RPCManager.send("getData", function (rpcResponse, data, rpcRequest) { // myGrid.setData(data)// });// </pre>//// @see class:RPCRequest// @see class:RPCResponse// @treeLocation Client Reference/RPC// @visibility external//<// ---------------------------------------------------------------------------------------//> @class RPCResponse//// Encapsulates an RPC response from the server. Instances of this class are automatically created// and optionally passed to you in the callback you specify as part of your RPCRequest.//// @see class:RPCRequest// @see type:RPCCallback// @visibility external// @treeLocation Client Reference/RPC//<//> @attr rpcResponse.data (boolean : false : R)// The data sent by the server.// <P>// When communicating with the SmartClient server, rpcResponse.data is the data passed to the// server-side method RPCResponse.setData() by your Java code, as translated into JavaScript// objects by the rules described under +link{rpcRequest.data}.// <P>// When not communicating with the SmartClient server (+link{rpcRequest.useSimpleHttp} or// another flag that implies it is set), rpcResponse.data contains the raw HTTP response body.// For an exception, see +link{rpcRequest.evalResult}.// // @visibility external//<//> @attr rpcResponse.status (integer : false : R)// // Status code for this response. Status codes less than zero are considered errors by the// RPCManager, those greater than or equal to zero are considered successes. Please see the// error handling section the +link{class:RPCManager,RPCManager docs} for more information on// what the RPCManager does with the status code and how you can override this behavior.// <P>// When using the SmartClient server you can set the rpcResponse.status by calling the// server-side method RPCResponse.setStatus(). // <P>// When not using the SmartClient server, the RPCManager makes no assumptions about the// structure of the response, so the status code just reflects the// +link{attr:RPCResponse.httpResponseCode}: status will be // +link{RPCResponse.STATUS_TRANSPORT_ERROR,STATUS_TRANSPORT_ERROR} if an HTTP-level error// occurred such as "500 server error". If you have a status code you need to transmit you can// simply embed it in the response (as part of +link{rpcResponse.data}) and interpret it from// the callback.// <P>// With or without the SmartClient server, the +link{group:relogin} status codes (such as // +link{STATUS_LOGIN_REQUIRED}) are triggered whenever special markers, such as the// loginRequiredMarker, appear in the body of the response. See the +link{group:relogin,Relogin// Overview} for details.//// @visibility external//<//> @attr rpcResponse.httpResponseCode (integer : null : R) //// This attribute (avialable when using the the <code>xmlHttpRequest</code> transport) contains// the HTTP response code sent by the server.// <p>// Note that this is different from +link{attr:RPCResponse.status} - that attribute is used to// indicate a status code for the RPC itself whereas httpResponseCode is the raw HTTP response// code for the HTTP request that contained the RPCRequest.// <p>// This feature relies on the XMLHttpRequest object which can be disabled by end-users in some// supported browsers. See +link{group:platformDependencies} for more information.// <p>// If you're using this attribute, you'll typically want to avoid the default error// handling response of RPCManager. To do so, set// +link{attr:rpcRequest.willHandleError} to <code>true</code>.//// @visibility external//<//> @attr rpcResponse.clientContext (Object : null : R)//// The +link{RPCRequest.clientContext} object as set on the +link{RPCRequest}.//// @see rpcRequest.clientContext//// @visibility external//<//> @attr rpcResponse.transactionNum (number : null : R)// ID of the transaction sent to the server via +link{RPCManager.sendQueue()} containing the// +link{RPCRequest} associated with this response.// @visibility external//<//> @type RPCTransport//// SmartClient supports multiple RPC transports for maximum compatibility and feature richness.// All of transports use HTTP as the underlying protocol, but use different mechanisms for// sending the HTTP request and processing the response. The transport is typically// auto-selected for by based on the feature being used and the current browser settings. For// advanced use cases, +link{RPCRequest.transport} and +link{RPCManager.defaultTransport} are// exposed as override points.// <p>// @value "xmlHttpRequest" Uses the XMLHttpRequest object to make the request to the server.// Note that in some browsers with certain configurations, this transport may not be// available. See +link{group:platformDependencies} for more information. This transport is// not useful with file uploads. Cannot be used to target cross-domain URLs directly.//// @value "scriptInclude" Write a SCRIPT tag into the DOM with a SRC attribute that targets// an arbitrary URL. This transport is the only one that allows direct cross-domain URL// access. // <P>// For +link{rpcRequest.callback} to work, the server being contacted must support the ability// to generate JavaScript code in the response that will call a JavaScript function generated// by SmartClient. SmartClient passes the name of the function to call via a URL parameter,// which can be controlled with +link{rpcRequest.callbackParam}.//// @value "hiddenFrame" Available with SmartClient Server only. An HTML form is// dynamically assembled that targets a hidden IFRAME. This mechanism is supported on all// browsers and cannot be disabled by end users. // <P>// If using the SmartClient Server and using // +link{group:serverDataIntegration,Server-side data integration}, the "hiddenFrame" transport// is automatically used for all RPCManager and DataSource requests if the "xmlHttpRequest"// transport is not available.// <P>// Cannot be used to target cross-domain URLs directly.////// @visibility external//<//> @groupDef platformDependencies//// Client-side processing of web services, XML parsing, and some UI loading mechanisms rely on// a native in-browser XML parser and/or the XMLHttpRequest object - one or both of which will// not be available if the end user disables ActiveX support in Internet Explorer. Note that// these features do not require plugins or downloads of any kind - IE simply exposes certain// built-in functionality like the XML parser and XMLHttpRequest through the ActiveX// interface. Disabling ActiveX also disables all browser plugins such as Flash, Java, SVG, etc.// <p>// Barring ActiveX being disabled, the XMLHttpRequest object is available to SmartClient on all// supported browsers and an XML parser is available on all supported browsers except Safari// versions prior to 3.0.3.// <p>// SmartClient client-server communication is not affected by the lack of an XML parser or the// XMLHttpRequest object, but the <code>xmlHttpRequest</code> transport will not be available// if the XMLHttpRequest object is not available. Instead, the <code>hiddenFrame</code> or the// <code>scriptInclude</code> transports are used for client-server communication.// <p>// <b><u>XML Parser</u></b>// <p>// If an XML Parser is not available to SmartClient, all client-side web service bindings and// related methods will be unavailable. Turning off ActiveX disables integration paths 2 and 3// in the diagram below. If you want to bind to web services and require deployment to IE// without ActiveX (or you need to support Safari pre 3.0.3), you'll need to do all XML processing on the// server and use either the SmartClient DSRequest or JSON operation pathways (integration// paths 1 and 4 in the diagram below). See the discussion in +link{clientServerIntegration}// for more information on the integration paths shown in the diagram below.// <p>// You call +link{XMLTools.nativeXMLAvailable()} to check for the avialability of a native XML// parser at runtime.// <p>// <img src="${isc.DocViewer.instance.referenceRoot}skin/ds_bindings.png" width=763 height=475>// <p>// <b><u>XMLHttpRequest</u></b>// <p>// The XMLHttpRequest object is used for the <code>xmlHttpRequest</code> +link{RPCTransport}.// Safari, Mozilla, Firefox, and IE 7 provide a native XMLHttpRequest implementation that is// not affected by ActiveX being disabled (although the native IE 7 implementation can still be// explicitly disabled by the end user). IE 5.5 and IE 6.0 rely on the ActiveX bridge to// support XMLHttpRequest, so if ActiveX is disabled in these browsers, XMLHttpRequest will not// be available.// <p>// The lack of the XMLHttpRequest objects affects UI loading features like +link{ViewLoader},// and +link{HTMLFlow} when used in remote loading mode (via +link{HTMLFlow.contentsURL},// +link{HTMLFlow.setContentsURL}, but does not affect the typical client/server communication// pathways (integration paths 1 and 5 in the diagram above).// <p>// Also affected are low level features +link{RPCRequest.serverOutputAsString},// +link{RPCRequest.evalResult}, and +link{RPCResponse.httpResponseCode}.// <p>// In all of the above cases, it is possible to use the <code>hiddenFrame</code> transport to// support these features when XMLHttpRequest is not available. SmartClient will automatically// send the request using the <code>hiddenFrame</code> transport when it detects that// XMLHttpRequest is unavailable. To support the above features, you'll need to use the// RPCManager APIs on the server to send back the data that would normally be returned by// XMLHttpRequest. Since XMLHttpRequest cannot target URLs outside of the current domain, this// strategy applies also to using the above features with cross-domain URLs.// <p>// You can call +link{RPCManager.xmlHttpRequestAvailable()} to check for the availability of// XMLHttpRequest at runtime.//// @title Platform Dependencies// @treeLocation /Client Reference/System// @visibility external//<isc.ClassFactory.defineClass("RPCResponse");isc.RPCResponse.addClassProperties({//> @groupDef statusCodes// Status codes returned by the server as rpcResponse.status.<br>// See the error handling doc section in +link{class:RPCManager, RPCManager} for more // information on these codes// @visibility external//<// NOTE: error codes are both added as a subobject (to allow code -> text name lookup) and// directly (via addProperties below)errorCodes : { //> @classAttr rpcResponse.STATUS_SUCCESS (integer : 0 : R) // // Indicates successful completion of the request. This is the default status and is // automatically used by the RPCResponse on the server unless you override it with // setStatus(). // <br><br> // See the error handling section in +link{class:RPCManager, RPCManager documentation} // for more information. // // @see class:RPCRequest // @group statusCodes // @visibility external //< STATUS_SUCCESS: 0, //> @classAttr rpcResponse.STATUS_FAILURE (integer : -1 : R) // // Indicates a generic failure on the server. // See the error handling section in +link{class:RPCManager, RPCManager documentation} // for more information. // // @see class:RPCRequest // @group statusCodes // @visibility external
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -