📄 datasource.js
字号:
/*
* Isomorphic SmartClient
* Version 6.5 (2008-04-30)
* Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
* "SmartClient" is a trademark of Isomorphic Software, Inc.
*
* licensing@smartclient.com
*
* http://smartclient.com/license
*/
//> @class DataSource// A DataSource is data-provider-independant description of a set of objects// that will be loaded, edited and saved within the user interface of your application.// <P>// Each DataSource consists of a list of +link{dataSource.fields,fields} that make up a// DataSource <code>record</code>, along with +link{dataSourceField.type,field types}, // +link{dataSourceField.validators,validation rules}, // +link{dataSourceField.foreignKey,relationships} to other DataSources, and other// metadata.// <P>// The abstract object description provided by a DataSource is easily mapped to a variety of// backend object models and storage schemes. The following table shows analogous terminology// across systems.// <table border=1 class="normal">// <tr>// <td>Isomorphic SmartClient</td>// <td>Relational Database</td>// <td>Enterprise Java Beans (EJB)</td>// <td>Entity/Relationship Modelling</td>// <td>OO/UML</td>// <td>XML Schema/WSDL</td>// <td>LDAP</td>// </tr><tr>// <td>DataSource</td>// <td>Table</td>// <td>EJB class</td>// <td>Entity</td>// <td>Class</td>// <td>Element Schema (ComplexType)</td>// <td>Objectclass</td>// </tr><tr>// <td>Record</td>// <td>Row</td>// <td>EJB instance</td>// <td>Entity instance</td>// <td>Class instance/Object</td>// <td>Element instance (ComplexType)</td>// <td>Entry</td>// </tr><tr>// <td>Field</td>// <td>Column</td>// <td>Property</td>// <td>Attribute</td>// <td>Property/Attribute</td>// <td>Attribute or Element (SimpleType)</td>// <td>Attribute</td>// </tr></table>// <P>// DataSources can be +link{group:dataSourceDeclaration,declared} in either JavaScript or XML// format, and can also be +link{group:metadataImport,imported} from existing metadata formats,// including XML Schema.// <P>// <i>Data Binding</i> is the process by which// +link{dataBoundComponent,Data Binding-capable UI components} can automatically configure// themselves for viewing, editing and saving data described by DataSources. DataBinding is// covered in the +docTreeLink{QuickStartGuide,QuickStart Guide}, Chapter 6, <i>Data// Binding</i>.// <P>// +link{group:clientServerIntegration,Data Integration} is the process by which a DataSource// can be connected to server systems such as SQL DataBases, Java Object models, WSDL web// services and other data providers. Data Integration comes in two variants: client-side and// server-side. +link{group:serverDataIntegration,Server-side integration} uses the// SmartClient Java-based server to connect to data represented by Java Objects or// JDBC-accessible databases. +link{group:clientDataIntegration,Client-side integration}// connects SmartClient DataSources to XML, JSON or other formats accessible via HTTP.// <P>// DataSources have a concept of +link{group:dataSourceOperations,4 core operations} ("fetch",// "add", "update" and "remove") that can be performed on the set of objects represented by a// DataSource. Once a DataSource has been integrated with your data store, databinding-capable // UI components can leverage the 4 core DataSource operations to provide many complete user// interactions without the need to configure how each individual component loads and saves// data.// <P>// These interactions include +link{listGrid,grid views}, +link{TreeGrid,tree views}, // +link{detailViewer,detail views}, +link{DynamicForm,form}-based // +link{dynamicForm.editRecord,editing} and +link{dynamicForm.saveData,saving},// grid-based +link{listGrid.canEdit,editing} and +link{listGrid.saveByCell,saving},// and custom interactions provided by +explorerExample{patternReuse} custom// databinding-capable components.// // @see interface:DataBoundComponent for information on DataBound Components// @see group:dataSourceDeclaration for how to create DataSources// @treeLocation Client Reference/Data Binding// @visibility external//<isc.defineClass("DataSource");//> @type DSOperationType// One of the four basic operations that can be performed on DataSource data: "fetch",// "add", "update", "remove". Elsewhere called CRUD operations, where CRUD stands for// "create", "retrieve", "update", "delete", which correspond to "add", "fetch", "update" and// "remove" in SmartClient terminology. See +link{group:dataSourceOperations} for a full// description.//// @value "fetch" Fetch one or more records that match a set of search criteria.// @value "add" Store new records// @value "update" Update an existing record// @value "remove" Remove (delete) an existing record//// @visibility external//<//> @groupDef dataSourceDeclaration// DataSources can be specified in XML format, in which case the ISC server is used to load the// DataSource in a JSP file, or DataSources can be directly created on the client via// JavaScript.// <P>// Whether a DataSource is specified in XML or JS, identical requests will ultimately be// submitted to the server, so the server integration pattern is the same. However,// DataSources created in XML are understood by the ISC server, allowing shared validation// rules declared in the DataSource to be executed automatically on both the client and// server. Further, for prototyping purposes, the ISC server supports SQL connectivity for// DataSources specified in XML. This SQL connectivity allows complete database-driven// applications to be created without writing any server integration code.// <P>// DataSources created on the client use the same style of creation as DataBound components:// <pre>// DataSource.create({// ID:"supplyItem",// fields:[// {name:"itemName", ... }// ...// ]// });// </pre>// Reference for all properties that can be set for DataSources, their fields and validators is// given in the +link{class:DataSource} class reference.// <P>// XML DataSources use a direct analogue of this format:// <pre>// <DataSource ID="supplyItem">// <fields>// <field name="itemName" type="text" title="Item"/>// <field name="SKU" type="text" title="SKU">// <validators>// <validator type="integerRange" ... />// </validators>// </field>// </fields>// </DataSource>// </pre>// XML DataSources are loaded via a special JSP tag supported by the ISC Server:// <pre>// <%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>// ...// <SCRIPT>// <isomorphic:loadDS ID="supplyItem"/>// </SCRIPT>// </pre>// When loading an XML DataSource, by default, the ISC Server will look for a file named// <code><dataSourceId>.ds.xml</code> in the <code>/shared/ds</code> subdirectory under// webroot. The location of this directory can be changed, or individual DataSources can be// placed in arbitrary locations. For more information, see// <code>[webroot]/WEB-INF/classes/server.properties</code>.// <p>//// @see class:DataSource// @see group:loadDSTag// @treeLocation Client Reference/Data Binding/DataSource// @title Creating DataSources// @visibility external//<//> @groupDef i18n//// <b><u>Internationalizing SmartClient UI Components</u></b>// <p>// Internationalizing a SmartClient application involves creating locale-specific// versions of all strings, images, and possibly colors. In some cases, component layout may// be affected as well (for example date field order differs between some locales).// <p>// <u><b>Character Encodings</b></u>// <p>// In order to deliver content in different languages to the browser and have it be displayed// correctly, it is important that the browser and server agree on the character encoding being// used to send the page. // <p>// Generally speaking, you can use whatever character encoding you prefer, so long as// as you're consistent about serving your files to the browser with exactly the same encoding// as was used to save the file to disk. Keep in mind though that the character encoding you// choose must be supported by all browsers you intend to support. Isomorphic recommends that,// where possible, you use the UTF-8 encoding. Regardless of which character encoding you// choose, keep in mind that for the browser to correctly display non-ASCII characters, you// <b>must</b> explicitly set the character encoding of your page to match the encoding you// used to save the file. Browsers have built-in heuristics to guess the character encoding,// but they can't be relied upon to work 100% of the time.// <p>// There are two ways to explicitly tell the browser what character// encoding is being used for a given page. One is to set the "Content-Type" header - e.g. as// follows in a raw HTTP response to set UTF-8 character encoding and a text/html mime type:// <pre>// Content-Type: text/html; charset=UTF-8// </pre>// If you're using Java on the back-end, you can set this header out of JSP as follows:// <pre>// <%@ page contentType="text/html; charset=UTF-8"%>// </pre>// Or using Java Servlet APIs in a Servlet as follows:// <pre>// response.setContentType("text/html; charset=UTF-8");// </pre>// Note that the latter needs to be done before any content is written to the response output// stream.// <p>// The other approach to setting the content encoding is to use an HTML META tag to embed it// in the page itself (note that this applies to HTML documents only). The META tag must go// inside the <HEAD> HTML element - e.g. as follows:// <pre>// <HEAD>// <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">// </HEAD>// </pre>// Isomorphic recommends that you use <b>both</b> of these approaches for maximum// compatibility. For example, if you omit the META tag approach, documents saved by the user// using the browser save function may not render correctly when subsequently read from disk// because HTTP headers are not available in that context. And conversely not providing the// HTTP header can result in application servings applying their own default and incorrect// content encoding.// <p>// If you're using a given character encoding pervasively in your pages, you can also configure// your web server or application server to use that character encoding as the default for all// pages of a given mime type or some other criteria (depending on the capability of your// server) - for example on a per-directory basis.// <p>// For more information on character encodings, character sets, and working with HTML, please
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -