⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datasource.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
// Ajax request without reloading the page or launching sub-windows.// <P>// Uploaded files arrive at the SmartClient server as Java InputStreams accessible from the// DSRequest object, and can optionally be automatically stored via SmartClient's SQL// subsystem.// <P>// <h4>Transparent Queuing / "Batch" Operations</h4>// <P>// Any request transmitted to the SmartClient Server can be combined into a "queue" transmitted// as a single HTTP request, with in-order execution for all queued operations. // +link{RPCManager.startQueue,startQueue()} starts a queue and// +link{RPCManager.sendQueue,sendQueue()} transmits it; queueing is transparent to the code// that initiates the individual requests.  This enables:// <ul>// <li> re-use of data access operations across different screens// <li> easy implementation of transaction boundaries// <li> simplified saving and loading of screens with complex, master-detail views// <li> guaranteed in-order processing of operations// <li> more efficient network usage// </ul>// <P>// <h4>Visual Builder</h4>// <P>// +link{group:visualBuilder,Visual Builder} is included with the SmartClient Server, and uses// server features such as automatic SQL binding to provide a rapid prototyping environment.// <P>// <h4>Automatic Bi-directional Java &lt; - &gt; JavaScript serialization and translation</h4>// <P>// Provides a powerful, type-safe +link{rpcRequest.data,data transmission mechanism} for moving// data between a Java server and the browser. // <P>// Any Java objects, including Java Beans, POJOs, Java Collections, XML DOMs and all Java// primitives, with any level of nesting, can be automatically serialized and delivered as// JavaScript Objects to the SmartClient client-side components.// <P>// JavaScript Objects existing in the browser can likewise be automatically transmitted to a// Java Server and translated to Java Objects, with any level of nesting and automatic// preservation of primitive types.// <P>// <h4>Rich, Standardized Request / Response protocol</h4>// <P>// The SmartClient Server provides a standardized request and response protocol designed for// data-oriented "CRUD" operations (create, retrieve, update, delete).// <P>// This standardized protocol automatically handles +link{DSRequest,request metadata} (paging// parameters, requested sort order, original values of data being modified) and// +link{DSResponse,response metadata} (error handling, cache management, session expiration etc).// <P>// Similar to the impact of Struts on early web applications, this standardized protocol avoids// developers in different groups inventing their own incompatible and redundant// request/response protocols, and allows developers to more easily learn code they didn't// author.// <P>// <h4>Bi-directional XPath binding to Java Objects</h4>// <P>// Most UI designs do not directly reflect the underlying Object model and so some degree of// translation is necessary in order to populate UI components with data and apply user changes// to the Java Object model.  This is often accomplished with brittle, difficult to understand// data translation code sprinkled throughout the system, done in a different way for every// screen or component.// <P>// SmartClient provides a standard, +link{dataSourceField.valueXPath,XPath-based approach} to// adapting any Java-based Object model to the requirements of the UI design.  Data relevant to// the application UI is centrally extracted in the server-side +link{DataSource} layer, so// that all UI components have a consistent, unified view of the data model for both loading// <b>and</b> saving data.// <P>// <h4>Broadest possible browser support</h4>// <P>// The SmartClient Server can compensate for facilities // +link{group:platformDependencies,missing or disabled in certain browsers},// including ActiveX being disabled in IE6 and missing XML support in some versions// of Apple's Safari browser.// <P>// <h4>Transparent Proxying</h4>// <P>// +link{RPCManager.sendProxied,Proxying} allows SmartClient applications to access web// services, RSS feeds, HTML content and other data services in a secure manner regardless of// where they are located: across the enterprise or publicly available.// <P>// <h4>Optional +link{group:networkPerformance,Network Performance} Module</h4>// <P>// Provides:// <ul>// <li> compressed delivery of SmartClient runtime, application logic and other assets such as CSS// <li> +link{FileLoader,background download} of SmartClient and other assets for zero// user-perceived load time// <li> on-the-fly stripping, combining and obfuscation of JavaScript (application code and data)// <li> browser cache control// </ul>// <P>// <h4>Optional Messaging Module (aka server push)</h4>// <P>// The +docTreeLink{messaging,Messaging} module allows the server to "push" messages to the client, without// client polling, for real-time monitoring/dashboarding applications.//// @title SmartClient Server Summary// @treeLocation Java Server Reference// @visibility external//<//> @groupDef jsfIntegration//// SmartClient can be used within JSF applications to add AJAX richness and interactivity.// <P>// Because +link{group:iscJSF,JSF is a pre-AJAX architecture}, the recommended approach in adding// SmartClient to JSF applications is to create pages that use SmartClient components exclusively,// so that older, server-based JSF components do not introduce full-page refreshes.// <P>// JSF pages that render components on the server access data via JSF Expression Language.// SmartClient-based JSF pages can similarly load initial data by using JSTL, as shown in the// +externalLink{/examples/server_integration/#jstlList,this example}, where a ListGrid is// populated by JSTL access to Java Beans stored in the JSP <code>pageContext</code>.  // <P>// Once a SmartClient JSF page has loaded, SmartClient components will request data via background// HTTP requests that load only data, not a complete page.  The // +link{class:DMI,Direct Method Invocation} system can be used to declaratively map SmartClient's// background data requests directly to Java Methods. The SmartClient server automatically// translates inbound request data into Java Objects that are passed to the method you specify,// and the Java method return value is automatically translated into data for SmartClient// components.// <P>// <h4>Incorporating server-side JSF components into a SmartClient JSF page</h4>// <P>// An +link{HTMLFlow} or +link{HTMLPane} component can be used to incorporate server-generated// content within a SmartClient-based page.  With +link{htmlFlow.contentsType,contentsType} set to// "page", the HTMLPane/Flow will act like a standalone page-within-a-page (via a// SmartClient-managed HTML IFRAME element), allowing interactive server-side JSF components to// participate normally, with limitations as discussed under the documentation for // +link{htmlFlow.contentsType,contentsType}.//// @treeLocation Concepts// @title Integration with JSF// @visibility external//<//> @groupDef strutsIntegration//// <b>Overview of SmartClient integration with Struts and other popular server-side// frameworks.</b>// <p>// Current and upcoming server-side frameworks solve a lot of problems endemic to the past// generation of web applications.  Piles of JSPs and Servlets have been replaced by MVC and// other paradigms that enhance developer productivity.  Unfortunately the end-user// presentation remains vanilla HTML.  SmartClient solves this problem by providing rich// databindable components. SmartClient was designed to integrate cleanly with existing// server-side frameworks.  Because SmartClient components only require an HTML context to// render, they can be used with any server-side frameworks that use HTML for presentation.// <p>// SmartClient provides a rich UI by doing more work on the client (browser) rather than// sending every user action to the server for re-rendering.  Instead of doing page transitions// to redraw the whole page, SmartClient sends RPC (Remote Procedure Call) requests (or AJAX// requests) to the server while the UI allows the user to continue interacting with the// system.  Current server-side frameworks, on the other hand are typically designed around// page transitions - for example in Struts user actions are typically mapped to URLs that// dispatch through a central servlet and ultimately return new HTML to be rendered by the// browser.  The problem with page transitions is that they destroy client-side state and// introduce client-server latency (and generally use more bandwidth since HTML is sent over// the wire rather than just data) - essentially destroying a large part of the Rich// Internet Application (RIA) experience.// <p>// Fortunately, there's a way to get the best of both worlds - to leverage the power of your// favorite server-side framework and combine it with the SmartClient UI.  There are several// approaches to integrating SmartClient into an existing framework:// <p>// <u><b>Plug-replacing HTML components with SmartClient components</b></u>// <p>// SmartClient components can be instructed to draw at page load time using by specifying// <code>position: "relative"</code> at construction time.  This enables you to replace any// chunk of HTML with a SmartClient component - the new component simply inserts its HTML in// the page flow during page load.  This is the easiest integration option - you get a better// UI with minimal work.  The downside is that you don't get the full power of a rich client// because most user actions will still trigger a page transition.// <p>// <u><b>Eliminating page transitions</b></u>// <p>// Most SmartClient components can accept new data (or even dynamically pre-fetch and expire// data) without needing to be recreated.  For example - let's say you want to draw a grid on a// page.  In a traditional server-side-rendered application the server would generate all of// the html with a "next 20 records" and "previous 20 records" buttons. When the user wants to// see the next set of data, he clicks one of the buttons and the server replaces the entire// page with a new grid that contains the next/previous 20 records.  In a SmartClient// application, you would create a databound ListGrid.  Based on its configuration this grid// will fetch the first N (say 20) records and display a scrollbar for the user to scroll// through the data.  When the user scrolls off the last cached record the ListGrid// automatically sends an RPC to the server asking for the next 20 records.  This RPC (fetch)// is performed without destroying the page the user is currently looking at - it just happens// seamlessly in the background.  If the user now scrolls back to the first 20 records -// they're already cached in the grid, so no fetch is performed.  Of course, in a real world// application, it's typical that a page has hundreds of components and in a server-side-only// rendering all of them need to be rebuilt by the server and resent to the client when a piece// of data in just one needs to be updated.  SmartClient components can intelligently update// just their data without the need to redraw the whole page.// <p>// The plug-replacement strategy listed above gives us a SmartClient component in place of a// raw HTML rendering.  Now we need to databind that component so that actions like scrolling a// grid or validating a form don't cause a page transition.  The SmartClient RPC mechanism has// a default actionURL that's configurable by the end user.  This allows you to funnel all RPC// requests through a central dispatcher like the Struts Action servlet.// SmartClient RPCs are just HTTP requests with XML payloads that can be accessed using the// provided Java APIs (RPCManager Java class and associated classes).  On the other hand you// can decide to have the SmartClient RPCs work out of band of something like the Action// servlet - the choice is up to you.  Usually funnelling through the Action servlet makes// sense if you have a need to centrally capture all requests - for example for later playback// during load or QA testing.// <p>// Here's what the code would look like to accomplish the funneling (for example with the// Struts Action servlet):// <pre>// On the client - the following line of code forces all SmartClient RPC requests to make// requests to the /smartClientRPC.do URL that would then be intercepted by the Action servlet -// assuming you have the standard *.do mapping for it in your web.xml.//// RPCManager.addProperties({ actionURL: "/smartClientRPC.do"});//// On the server, you would then create an action mapping for the "/smartClientRPC" path// that you would forward to a custom Action handler.  For example you could have this in your// struts config.xml://// &lt;action path="/smartClientRPC" type="com.your.company.name.SmartClientRPCAction"/&gt;// // In your Action execute() method you have access to the HttpServletRequest and// HttpServletResponse objects - which is all you need to instantiate the RPCManager class// that's part of the SmartClient server-side SDK that you can then use to obtain the RPC// payload.  Like this://// RPCManager rpc = new RPCManager(request, response);// Object data = rpc.getData();// rpc.send("here's a response");// </pre> // Given this configuration, all databound components will send their requests through this// pipeline and you need only write the code to respond to e.g. a given ListGrid's request to// get the next 25 rows.  For custom RPCs, you can specify actionURLs in the RPCRequest itself// that override the RPCManager default that you can then use to target different actions - in// other words you need not dispatch all SmartClient RPCs through a single Struts Action.// <p>// <u><b>Struts examples in the SDK</b></u>// <p>// The SDK contains a simple example of doing form validation without incurring a page// transition. These examples also show how to populate e.g. field names using the struts-bean// taglib and how to set validation errors using the standa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -