SmartClient Quick Start Guide
SmartClient Quick Start Guide
SmartClient v13.1
SmartClient™ Quick Start Guide
Copyright ©2024 and beyond Isomorphic Software, Inc. All rights reserved. The
information and technical data contained herein are licensed only pursuant to a license
agreement that contains use, duplication, disclosure and other restrictions; accordingly, it
is “Unpublished-rights reserved under the copyright laws of the United States” for
purposes of the FARs.
Web: www.isomorphic.com
Email: info@isomorphic.com
Disclaimer of Warranties
THE INFORMATION CONTAINED HEREIN IS PROVIDED “AS IS” AND ALL EXPRESS
OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT AND ONLY TO
THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
SmartClient Quick Start
Contents
Contents .....................................................................................ii
How to use this guide ................................................................. v
Why SmartClient? ..................................................................... vi
More than Just Widgets —A Complete Architecture .................... vi
Eliminates Cross-Browser Testing and Debugging ....................... vi
Complete Solution ........................................................................ vii
Open, Flexible Architecture.......................................................... vii
Reify & Hybrid Development ...................................................... viii
1. Overview ............................................................................... 1
Architecture ..................................................................................... 1
Capabilities and Editions of SmartClient ....................................... 2
Standard Capabilities ..................................................................... 3
Optional Modules ........................................................................... 4
SDK Components ........................................................................... 5
2. Installation ............................................................................ 6
Requirements ................................................................................. 6
Steps ................................................................................................7
Server Configuration (optional) ..................................................... 9
3. Resources ............................................................................ 10
Showcase .......................................................................................10
Demo Application.......................................................................... 11
Developer Console ......................................................................... 12
Reference ....................................................................................... 17
Community Wiki ...........................................................................18
4. Coding ................................................................................. 19
Languages ...................................................................................... 19
Headers ........................................................................................ 20
Components .................................................................................. 21
Hello World .................................................................................. 23
Deploying ..................................................................................... 24
5. Visual Components ............................................................. 25
Component Documentation & Examples ..................................... 25
Identifying Components ............................................................... 25
Manual Layout.............................................................................. 26
Drawing, Hiding, and Showing Components ............................... 28
Handling Events ........................................................................... 28
6. Data Binding ....................................................................... 30
Databound Components .............................................................. 30
Fields ............................................................................................ 30
Form Controls .............................................................................. 33
DataSources .................................................................................. 34
DataSource Operations ................................................................ 39
ii Isomorphic Software
SmartClient Quick Start
iv Isomorphic Software
SmartClient Quick Start
This is an interactive manual. You will receive the most benefit from this
guide if you are working in parallel with the SmartClient SDK—following
the documented steps, creating and modifying the code examples, and
finding your own paths to explore. You may want to print this manual for
easier reference, especially if you are working on a single-display system.
We assume that you are somewhat acquainted with basic concepts of web
applications (browsers, pages, markup, scripting), object-oriented
programming (classes, instances, inheritance), and user interface
development (components, layout, events). However, you do not need
deep expertise in any specific technology, language, or system. If you
know how to navigate a file system, create and edit text files, and open
URLs in a web browser, you can start building rich web applications with
SmartClient today.
v Isomorphic Software
SmartClient Quick Start
Why SmartClient?
Smart Client helps you to build and maintain more usable, portable,
efficient web applications faster, propelled by an open, extensible stack of
industry-tested components and services.
Even if you adopt only part of the SmartClient solution, you benefit from
an architecture that takes into account the entire problem you need to
solve, not just a part of it. Every integration point in the SmartClient
platform has been designed with a clear understanding of the
requirements you need to fulfill, and, the solutions built into SmartClient
provide a “blueprint” for one way of meeting those requirements.
Even if you need to create a totally unique look and feel, SmartClient’s
simplified skinning and branding requires only basic knowledge of page
styling, and you never have to deal with browser layout inconsistencies.
vi Isomorphic Software
SmartClient Quick Start
Complete Solution
SmartClient offers a complete presentation layer for enterprise
applications: everything you need for the creation of full-featured, robust,
high-productivity business applications.
Reify lets your design team build the simpler stuff, while your developers
focus on the hard stuff. Imagine the productivity that’s possible when
your development and design team can work concurrently on the same
application, neither blocked on the other!
To learn more about Reify, please visit Reify.com for a free trial account
and free tutorials."
Architecture
The SmartClient architecture spans client and server, enabling Rich
Internet Applications (RIAs) that communicate transparently with your
data and service tiers.
Client Server
Finally, note that SmartClient does not require that you adopt this entire
architecture. You may choose to integrate with only the layers and
components that are appropriate for your existing systems and
applications.
http://www.SmartClient.com/product
2 Isomorphic Software
SmartClient Quick Start
Standard Capabilities
The standard capabilities of the SmartClient web presentation layer
include:
Area Description
Foundation SmartClient class system, data types, JavaScript
Services extensions, and browser utilities.
Foundation Building-block visual components, including
Components Canvas, Img, StretchImg, and StatefulCanvas.
3 Isomorphic Software
SmartClient Quick Start
Optional Modules
Isomorphic also develops and markets the following optional modules to
extend the standard SmartClient system. For more information on these
modules, see SmartClient Reference → Optional Modules.
Option Description
SmartClient Provides direct Java APIs for databinding and
Server low level client-server communications, deep
integration with popular Java technologies such
as Spring, Hibernate, Struts, and others.
Extensive server-side validators that match the
client-side versions and work automatically. For
more information, please see the “SmartClient
Server Feature Summary” in the Concepts
section of the SmartClient Reference.
Analytics Multi-dimensional data binding and interactive
CubeGrid components (cross-tabs, dynamic data
loading, drag-and-drop pivoting).
Real-Time Real-time, server push messaging over HTTP,
Messaging with Java Message Server (JMS) backed publish
and subscribe services.
Network File packaging, caching, and compression
Performance services for optimal performance of distributed
applications.
4 Isomorphic Software
SmartClient Quick Start
SDK Components
The SmartClient Software Developer Kit (SDK) includes extensive
documentation and examples to accelerate you along the learning curve.
These resources are linked from the SDK Explorer, and are available in
the docs/ and examples/ directories of your SDK distribution.
5 Isomorphic Software
SmartClient Quick Start
2. Installation
Requirements
To facilitate an initial evaluation with minimum prerequisites, the
SmartClient SDK distribution includes an embedded application server
6 Isomorphic Software
SmartClient Quick Start
Steps
To install and start your SmartClient development environment:
7 Isomorphic Software
SmartClient Quick Start
8 Isomorphic Software
SmartClient Quick Start
9 Isomorphic Software
SmartClient Quick Start
3. Resources
Showcase
From the SmartClient SDK Explorer, pick Showcase. When the
Showcase has loaded, you should see the following screen:
The code for the examples in the Showcase can be edited within the
Showcase itself, however, changes will be lost on exit. To create a
permanent, standalone version of an example found in the Showcase,
copy the source code into one of the templates in the templates/ directory
(discussed in more detail in Headers of the next chapter, Coding).
All of the resources used by the Showcase are also available in the
isomorphic/system/reference/ directory. In particular, exampleTree.xml
establishes the tree of examples on the left hand side of the Showcase
interface, and contains paths to example files in the inlineExamples/
10 Isomorphic Software
SmartClient Quick Start
Demo Application
From the SmartClient SDK Explorer, pick Docs then Demo App. The
first launch of this application will take several seconds, as the application
server parses and compiles the required files. When the application has
loaded, you should see the following screen:
The SmartClient SDK provides two versions of the code for this
application, one in JavaScript and one in XML, to demonstrate alternate
coding formats.
To explore the application code for this application, click on the XML or
JS links underneath the Demo App icon in the SDK Explorer. You can
11 Isomorphic Software
SmartClient Quick Start
also view and edit the source code for this application directly from the
isomorphic/system/reference/inlineExamples/demoApp/ directory in the
SDK. After you make changes to the code, simply reload the page in your
web browser to see the results.
Developer Console
The SmartClient Developer Console is a suite of development tools
implemented in SmartClient itself. The Console runs in its own browser
window, parallel to your running application, so it is always available in
every browser, and in every deployment environment. Features of the
Developer Console include:
• logging systems
• runtime code inspection and evaluation
• runtime component inspection
• tracing and profiling
• integrated reference docs
You can open the Developer Console from any SmartClient-enabled page
by typing javascript:isc.showConsole() in the address bar of your web
12 Isomorphic Software
SmartClient Quick Start
browser. Try it now, while the demo application is open in your browser.
The following window will appear:
13 Isomorphic Software
SmartClient Quick Start
14 Isomorphic Software
SmartClient Quick Start
In Firefox/Mozilla:
15 Isomorphic Software
SmartClient Quick Start
In Internet Explorer:
Click on the small Isomorphic logo in the Address bar and drag it to
your Links toolbar
If a dialog appears saying “You are adding a favorite that may not be
safe. Do you want to continue?”, click Yes.
16 Isomorphic Software
SmartClient Quick Start
Reference
The core documentation for SmartClient is the SmartClient Reference, an
interactive reference viewer implemented in SmartClient. You may access
the SmartClient Reference in any of the following ways:
If you are new to SmartClient, you may want to read the conceptual topics
in the SmartClient Reference for more detail after completing this Quick
17 Isomorphic Software
SmartClient Quick Start
Start guide. These topics are indicated by the blue cube icon ( ) in the
reference tree.
Community Wiki
The wiki is a place where community members and Isomorphic engineers
can work together to add new documentation and new samples -
especially samples and documentation involving third-party products,
where it would not be possible to create a standalone running sample in
the SDK.
This is the right place to look for articles on how to integrate with a
specific authentication system, application server, reporting engine,
widget kit, cloud provider or similar major third-party product.
https://isomorphic.atlassian.net/wiki/spaces/Main/overview
18 Isomorphic Software
SmartClient Quick Start
4. Coding
Languages
SmartClient applications may be coded in:
SmartClient XML
• more efficient
• easier to read when declarative and procedural code
must be combined
• works in stand-alone examples (no server)
• allows programmatic (runtime) component
instantiation
Each format also has its quirks: In JS, missing or dangling commas are a
common cause of parsing errors. In XML, quoting and escaping rules can
make code difficult to read and write.
19 Isomorphic Software
SmartClient Quick Start
Headers
Every SmartClient application is launched from a web page, which is
usually called the bootstrap page. In the header of this page, you must
load the SmartClient client-side engine, specify a user interface “skin,”
and configure the paths to various SmartClient resources.
The exact format of this header depends on the technology you use to
serve your bootstrap page. The minimal headers for loading a
SmartClient-enabled .jsp or .html page are as follows.
20 Isomorphic Software
SmartClient Quick Start
need to change the file paths to locate the isomorphic/ directory. This
example assumes that the bootstrap page is located in a directory that is
adjacent to the isomorphic/ directory.
Note that both examples above load all standard modules. Your
application may need only some modules, or may also load the optional
modules discussed in Chapter 1.
Components
SmartClient is an object-oriented system. You assemble your web
application GUIs from SmartClient components. These components are
defined as reusable classes, from which you create specific instances.
Component classes and instances provide properties (aka attributes) that
you can set at initialization, and methods (aka functions) that you can call
at any time in your client-side logic.
For better readability, you can format your component constructors with
one property per line, as follows:
isc.Button.create({
title: "Click me",
width: 200
})
21 Isomorphic Software
SmartClient Quick Start
or in nested tags:
<Button>
<title>Click me</title>
<width>200</width>
</Button>
The latter format allows you to embed JS inside your XML code, e.g., for
dynamic property values, by wrapping it in <JS> tags:
<Button>
<title>
<JS>myApp.i18n.clickMe</JS>
</title>
<width>200</width>
</Button>
22 Isomorphic Software
SmartClient Quick Start
Hello World
The following examples provide the complete code for a SmartClient
“Hello World” page, in three different but functionally identical formats.
Try recreating these examples in your editor. You can save them in the
examples/ directory of the SmartClient SDK, with the appropriate file
extensions (.html or .jsp).
23 Isomorphic Software
SmartClient Quick Start
You can open the .html version directly from your file system (by double-
clicking the file’s icon), provided your browser allows interactive web
pages to run from your file system.
You must open the .jsp versions through your server, as follows:
http://localhost:8080/examples/helloworld.jsp
http://localhost:8080/examples/helloworldXML.jsp
Deploying
For instructions on deploying a SmartClient application, see:
24 Isomorphic Software
SmartClient Quick Start
5. Visual Components
Identifying Components
You can identify SmartClient components by setting their ID property:
isc.Label.create({
ID: "helloWorldLabel",
contents: "Hello World"
})
25 Isomorphic Software
SmartClient Quick Start
Manual Layout
You can configure and manipulate SmartClient components by setting
component properties and calling component methods. The most basic
properties for a visual component involve its position, size, and overflow:
• left
• top
• width
• height
• overflow
• position
26 Isomorphic Software
SmartClient Quick Start
left and top take integer values, representing a number of pixels from the
top-left of the component’s container (typically a web page, Layout,
Window, or TabSet). width and height take integer pixel values (default 100
for most classes), and can also take string percentage values (e.g. "50%").
For example:
isc.Label.create({
left: 200, top: 200,
width: 10,
contents: "Hello World"
})
In this example, the specified width is smaller than the contents of the
label, so the text wraps and “overflows” the specified size of the label. This
behavior is controlled by the overflow property, which is managed
automatically by most components. You may need to change this setting
for Canvas, Label, DynamicForm, DetailViewer, or Layout components
whose contents you want to clip or scroll instead. To do this, set the
overflow property to "hidden" (clip), "scroll" (always show scrollbars),
or "auto" (show scrollbars only when needed). For example:
isc.Label.create({
left: 200, top: 200,
width: 20,
contents: "Hello World",
overflow: "hidden"
})
<LI>first item</LI>
<LI>
<SCRIPT>
isc.Button.create({
title: "middle item",
position: "relative"
})
</SCRIPT>
</LI>
<LI>last item</LI>
27 Isomorphic Software
SmartClient Quick Start
In most applications, you will want more flexible, dynamic layout of your
visual components. Chapter 7 (Layout) introduces the SmartClient Layout
managers, which you can use to automatically size, position, and reflow
your components at runtime.
• autoDraw
• show()
• hide()
Handling Events
SmartClient applications implement interactive behavior by responding to
events generated by their environment or user actions. You can provide
the logic for hundreds of different events by implementing event
handlers.
28 Isomorphic Software
SmartClient Quick Start
isc.Button.create({
ID: "clickBtn",
title: "click me",
click: "isc.warn('button was clicked')"
})
For event handling in applications, you can set your event handlers to
strings that execute external functions. This approach enables better
separation of user interface structure and logic:
isc.Button.create({
ID: "clickBtn",
title: "click me",
click: "clickBtnClicked()"
})
function clickBtnClicked() {
isc.warn('button was clicked');
})
29 Isomorphic Software
SmartClient Quick Start
6. Data Binding
Databound Components
You can bind certain SmartClient components to DataSources that
provide their structure and contents. The following visual components are
designed to display, query, and edit structured data:
Fields
Fields are the building blocks of databound components and datasources.
There are two types of field definitions:
30 Isomorphic Software
SmartClient Quick Start
Component Fields
DynamicForm form controls
ListGrid columns & form controls
TreeGrid columns & form controls
CubeGrid (Analytics option) facets (row & column headers)
DetailViewer rows
TileGrid rows within tiles
Calendar event duration and description
You can specify the displayed fields of a visual component via the fields
property, which takes an array of field definition objects. For example:
isc.ListGrid.create({
ID: "contactsList",
left: 50, top: 50,
width: 300,
fields: [
{name:"salutation", title:"Title"},
{name:"firstname", title:"First Name"},
{name:"lastname", title:"Last Name"}
]
})
Try reproducing this example. When you load it in your web browser, you
should see a ListGrid that looks like this:
The name property of a field is the special key that connects that field to
actual data values. For a simple ListGrid or DetailViewer, you can specify
data values directly via the data property, which takes an array of record
31 Isomorphic Software
SmartClient Quick Start
The basic field definitions in the ListGrid above are reusable across
components. For example, you could copy these field definitions to create
a DynamicForm:
isc.DynamicForm.create({
ID: "contactsForm",
left: 50, top: 250,
width: 300,
fields: [
{name:"salutation", title:"Title"},
{name:"firstname", title:"First Name"},
{name:"lastname", title:"Last Name"}
]
})
32 Isomorphic Software
SmartClient Quick Start
Form Controls
Field definitions also determine which form controls are presented to
users, for editable data values in forms and grids. You can specify the
form control to use for a field by setting its editorType property.
The default editorType is "text", which displays a simple text box editor.
This control is an instance of the TextItem class.
To override the default form control for a field, set editorType to the class
name for that control, in lower case, minus the "Item". For example, for a
CheckboxItem, you can set editorType:"checkbox".
33 Isomorphic Software
SmartClient Quick Start
DataSources
SmartClient DataSource objects provide a presentation-independent,
implementation-independent description of a set of persistent data fields.
DataSources enable you to:
34 Isomorphic Software
SmartClient Quick Start
Specify a field element with a unique name (in this DataSource) for
each field that will be exposed to the presentation layer.
35 Isomorphic Software
SmartClient Quick Start
Now the components can reference this shared DataSource via their
dataSource properties, instead of specifying fields. The complete code for
a page that binds a grid and form to this DataSource is:
<%@ taglib uri="isomorphic" prefix="isomorphic" %>
<HTML><HEAD>
<isomorphic:loadISC />
</HEAD><BODY>
<SCRIPT>
<isomorphic:loadDS ID="contactsDS" />
isc.ListGrid.create({
ID: "contactsList",
left: 50, top: 50,
width: 500,
dataSource: contactsDS
});
isc.DynamicForm.create({
ID: "contactsForm",
left: 50, top: 200,
width: 300,
dataSource: contactsDS
});
</SCRIPT>
</BODY></HTML>
36 Isomorphic Software
SmartClient Quick Start
37 Isomorphic Software
SmartClient Quick Start
Property Values
name unique field identifier (required on every
DataSource field)
type “text” | “integer” | “float” | “boolean” |
“date” | “datetime” | “time” | “enum” |
“sequence” | “binary”
38 Isomorphic Software
SmartClient Quick Start
DataSource Operations
SmartClient provides a standardized set of data operations that act upon
DataSources:
39 Isomorphic Software
SmartClient Quick Start
or
contactsList.fetchData(
{lastname:"Glover"}
);
Method Description
editRecord() starts editing an existing record
editNewRecord() starts editing a new record
saveData() saves the current edits (Add new
records; Update existing records)
40 Isomorphic Software
SmartClient Quick Start
Convenience Method
listGrid.removeSelectedData()
dynamicForm.editSelectedData(listGrid)
detailViewer.viewSelectedData(listGrid)
examples/databinding/component_databinding.jsp shows
most of these DataSource and databound component
methods in action, with a ListGrid, DynamicForm, and
DetailViewer that are dynamically bound to several
different DataSources.
41 Isomorphic Software
SmartClient Quick Start
42 Isomorphic Software
SmartClient Quick Start
7. Layout
Component Layout
Most of the code snippets in this guide create just one or two visual
components, and position them manually with the left, top, width, and
height properties.
This manual layout approach becomes brittle and complex with more
components. For example, you may want to:
43 Isomorphic Software
SmartClient Quick Start
Member Description
property
layoutAlign alignment with respect to the breadth axis of
the layout ("left", "right", "top", "bottom",
or "center")
showResizeBar determines whether a drag-resize bar
appears between this component and the
next member in the layout
(true | false)
width layout-managed components support a "*"
or value (in addition to the usual number and
height
percentage values) for their size on the
length axis of the layout, to indicate that
they should take a share of the remaining
space after fixed-size components have been
counted (this is the default behavior if no
width/height is specified)
44 Isomorphic Software
SmartClient Quick Start
You can use the special LayoutSpacer component to insert extra space into
your layouts. For example, here is the code to create a basic page header
layout, with a left-aligned logo and right-aligned title:
isc.HLayout.create({
ID:"myPageHeader",
height:50,
layoutMargin:10,
members:[
isc.Img.create({src:"myLogo.png"}),
isc.LayoutSpacer.create({width:"*"}),
isc.Label.create({contents:"My Title"})
]
})
Container Components
In addition to the basic layout managers, SmartClient provides a set of
rich container components. These include:
45 Isomorphic Software
SmartClient Quick Start
Form Layout
Data entry forms have special layout requirements—they must present
their controls and associated labels in regularly aligned rows and
columns, for intuitive browsing and navigation.
When form controls appear in a DynamicForm, their positions and sizes are
controlled by the SmartClient form layout manager. The form layout
manager generates a layout structure similar to an HTML table. Form
controls and their titles are rendered in a grid from left-to-right, top-to-
bottom. You can configure the high-level structure of this grid with the
following DynamicForm properties:
DynamicForm Description
property
numCols Total number of columns in the grid, for form
controls and their titles. Set to a multiple of 2,
to allow for titles, so numCols:2 allows one
form control per row, numCols:4 allows two
form controls per row, etc.
titleWidth Number of pixels allocated to each title
column in the layout.
colWidths Optional array of pixel widths for all columns
in the form. If specified, these widths will
override the column widths calculated by the
form layout manager.
You can control the positioning and sizing of form controls in the layout
grid by changing their positions in the fields array, their height and
width properties, and the following field properties:
Field Description
property
colSpan number of form layout columns occupied by this
control (not counting its title, which occupies
another column)
rowSpan number of form layout rows occupied by this
control
startRow whether this control should always start a new
row (true | false)
endRow whether this control should always end its row
(true | false)
showTitle whether this control should display its title
(true | false)
46 Isomorphic Software
SmartClient Quick Start
Field Description
property
align horizontal alignment of this control within its area
of the form layout grid ("left", "right", or "center")
You can also use the following special form items to include extra space
and formatting elements in your form layouts:
• header
• blurb
• spacer
• rowSpacer
47 Isomorphic Software
SmartClient Quick Start
8. Data Integration
DataSource Requests
When a visual component, or your own custom code, attempts to use a
DataSource operation, a DSRequest (DataSource Request) is created
representing the operation. “Data Integration” is the process of fulfilling
that DSRequest by creating a corresponding DSResponse (DataSource
Response), by using a variety of possible approaches to connect to the
ultimate data provider.
48 Isomorphic Software
SmartClient Quick Start
Unless you are forced to use a different approach (for example, you are
not using a Java-based server, and cannot deploy a Java-based server in
front of your existing server), it is highly recommended that you use the
SmartClient Server Framework for data integration. The server
framework delivers an immense range of functionality that compliments
any existing application and persistence engine. Chapter 9, SmartClient
Server Framework, provides an overview.
If you cannot use the SmartClient Server Framework, the best approaches
for data integration are covered later in this chapter.
49 Isomorphic Software
SmartClient Quick Start
startRow and endRow: the range of records to fetch (if paging is active)
oldValues: values of the record before changes were made, for checking
for concurrent edits (all operations but “fetch”)
startRow and endRow: the range of records actually returned (if paging is
active)
errors:for a validation error response, fields that were invalid and error
messages for each
If you cannot use the server framework, but you are free to define the
format and content of messages passed between the browser and your
server, the simplest data integration approach is the RestDataSource class.
50 Isomorphic Software
SmartClient Quick Start
If, instead, you are required to integrate with a pre-existing service that
defines its own HTTP-based protocol, you can configure a subclass of the
DataSource class to customize the HTTP request format and the expected
format of responses.
For services that return XML or JSON data (including WSDL), you can
specify XPath expressions indicating what part of the data should be
transformed into dsResponse.data. If XPath expressions are not sufficient,
you can override DataSource.transformRequest() and
DataSource.transformResponse() and add JavaScript code to handle
those cases.
SmartClient Showcase
https://www.smartclient.com/smartclient/showcase/?id
=restEditSave
51 Isomorphic Software
SmartClient Quick Start
However, SmartClient does not require that a data provider implement all
of these capabilities. In fact, SmartClient is able to use a “flat file” as a
response to the “fetch” operation, and implement searching and sorting
behaviors within the browser.
52 Isomorphic Software
SmartClient Quick Start
53 Isomorphic Software
SmartClient Quick Start
If you are using the SmartClient Server Framework, see the Declarative
Security section of Chapter 8 for further authentication and authorization
features, including the ability to declare role-based security restrictions in
.ds.xml file, create variations on DataSource operations accessible to
different user roles, and create certain operations accessible to
unauthenticated users.
Relogin
When a user’s session has expired and the user tries to navigate to a
protected resource, typical authentication systems will redirect the user to
a login page. With Ajax systems such as SmartClient, this attempted
redirect may happen in response to background data operations, such as a
form trying to save. In this case, the form perceives the login page as a
malformed response and displays a warning, and the login page is never
displayed to the user.
The ideal handling of this scenario is that the form’s attempt to save is
“suspended” while the user re-authenticates, then is completed normally.
SmartClient makes it easy to implement this ideal handling through the
Relogin subsystem.
54 Isomorphic Software
SmartClient Quick Start
55 Isomorphic Software
SmartClient Quick Start
Here, the recordXPath selects a list of item elements. Since the intended
values for each DataSource field appear as a simple subelements of each
item element (e.g. description), the field name is sufficient to select the
correct values, and no explicit valueXPath needs to be specified.
Value Description
"getParams" Input data is encoded onto the dataURL, e.g.
http://service.com/search?keyword=foo
"postParams" Input data is sent via HTTP POST, exactly as
an HTML form would submit them
"soap" Input data is serialized as a SOAP message
and POST’d to the dataURL (used with WSDL
services)
56 Isomorphic Software
SmartClient Quick Start
WSDL Integration
SmartClient supports automated integration with WSDL-described web
services. This support augments capabilities for integrating with generic
XML services, and consists of:
57 Isomorphic Software
SmartClient Quick Start
You can create a DataSource that has manually declared fields and
invokes a web service operation by setting serviceNamespace to the
targetNamespace of the <definitions> element from the WSDL file, and
then setting wsOperation to the name of the web service operation to
invoke. In this usage:
For full read-write integration with a service that supports the basic
DataSource operations on persistent data, OperationBindings can be
declared for each DataSource operation, and the wsOperation property can
be used to bind each DataSource operation (fetch, update, add, remove) to
a corresponding web service operation.
58 Isomorphic Software
SmartClient Quick Start
DataSource Generation
The server framework allows you to generate DataSource descriptors
(.ds.xml files) from Java Beans or SQL tables. This can be done as either a
one-time generation step, or can be done dynamically, creating a direct
connection from the property definitions and annotations on your Java
Beans to your UI components.
As an example, if you had the Java Bean Contact, the following is a valid
DataSource whose fields would be derived from a Java Bean:
<DataSource ID="contacts" schemaBean="com.sample.Contact" />
The following DataSource would derive its fields from your database
columns (as well as being capable of all CRUD operations):
<DataSource ID="contacts" serverType="sql"
tableName="contacts" autoDeriveSchema="true" />
59 Isomorphic Software
SmartClient Quick Start
The default rules for mapping between Java and SQL types and
DataSourceField types are summarized in the following table:
60 Isomorphic Software
SmartClient Quick Start
For example, you may have a database column employment that stores a
one-character employment status code, and needs a valueMap to display
appropriate values to end users:
<DataSource ID="contacts" serverType="sql"
tableName="contacts" autoDeriveSchema="true">
<fields>
<field name="employment">
<valueMap>
<value ID="E">Employed</value>
<value ID="U">Unemployed</value>
</valueMap>
</field>
</fields>
</DataSource>
• DataSource.schemaBean
• DataSource.inheritsFrom
• DataSource.autoDeriveSchema
61 Isomorphic Software
SmartClient Quick Start
62 Isomorphic Software
SmartClient Quick Start
As your application grows, you can add Java logic or take over processing
at any point in the standard server flow. For example, you can:
63 Isomorphic Software
SmartClient Quick Start
For example, the following declaration indicates that all DSRequests for
this DataSource should go to the Java class com.sample.DMIHandler:
<DataSource ID="contacts" schemaBean="com.sample.Contact">
<serverObject className="com.sample.DMIHandler"/>
</DataSource>
64 Isomorphic Software
SmartClient Quick Start
DMI Parameters
Methods invoked via DMI can simply declare arguments of certain types,
and they are provided automatically.
When this method is called via DMI, it will be passed the current
DSRequest. If the method also needs the current HttpServletRequest , it
can simply be declared as an additional parameter:
public DSResponse fetch(DSRequest dsRequest, HttpServletRequest
request) {
This works for all of the common objects available to a servlet (such as
HttpSession) as well as all SmartClient objects involved in DSRequest
processing (such as DataSource).
65 Isomorphic Software
SmartClient Quick Start
For example, you might add criteria to a “fetch” request so that users
who are not administrators cannot see records that are marked
deleted.
if (!servletRequest.isUserInRole("admin")) {
dsRequest.setFieldValue("deleted", "false");
}
For this kind of error, the default client-side behavior will be to show
the error in the UI component where saving was attempted.
For this kind of error, the default client-side behavior is a dialog box
shown to the user, with the message “Failure” in this case. Customize
this via the client-side API RPCManager.setHandleErrorCallback() .
66 Isomorphic Software
SmartClient Quick Start
Note that many of the DMI use cases described above can alternatively be
achieved by adding simple declarations to your DataSource .ds.xml file—
this is covered in more detail in the upcoming Operation Bindings
section.
• com.isomorphic.datasource.DSRequest
• com.isomorphic.datasource.DSResponse
SmartClient Reference:
67 Isomorphic Software
SmartClient Quick Start
http://www.smartclient.com/index.jsp#userSpecific
Data
Returning Data
Whether you return data via DMI, via a custom DataSource, or via writing
your own servlet and directly working with the RPCManager class, data that
should be delivered to the browser is passed to the dsResponse.setData()
API.
This API can accept a wide variety of common Java objects and
automatically deliver them to the browser as Record objects, ready for
display by DataBound Components or processing by your code.
For example, if you are responding to a fetch, the following Java objects
will all translate to a List of Records if passed to setData().
Each Map becomes a Record and each key/value pair in each Map
becomes a Record attribute.
Any Collection of Java Beans, that is, Java Objects that use the Java
getPropertyName() / setPropertyName() naming convention
68 Isomorphic Software
SmartClient Quick Start
com.isomorphic.js.JSTranslater.toJS()
This means that if any DataSource can support the “update” operation,
the DataSource also supports batch editing of records in a ListGrid with
no additional code, since this just involves executing the “update”
operation multiple times. Likewise, in other instances in which
components automatically use queuing (such as removeSelectedData()
with multiple records selected, and multi-row drag and drop)
implementing singular DataSource operations means that batch
operations work automatically without additional effort.
69 Isomorphic Software
SmartClient Quick Start
70 Isomorphic Software
SmartClient Quick Start
When the client receives the response for an entire queue, each response
is processed in order, including any callbacks passed to DataBound
Component methods.
71 Isomorphic Software
SmartClient Quick Start
Operation Bindings
Operation Bindings allow you to customize how DSRequests are executed
with simple XML declarations.
72 Isomorphic Software
SmartClient Quick Start
These are both operations of type “fetch” on the same DataSource, and
they can be distinguished by adding an operationId to the Operation
Binding. For example, if you had written a DMI method that performs full
text search called “doFullTextSearch,” you could declare an
operationBinding like this:
<operationBinding operationType="fetch"
operationId="fullTextSearch">
<serverObject className="com.sample.DMIHandler"
methodName="doFullTextSearch"/>
</operationBinding>
You could now configure a ListGrid to use this Operation Binding via
grid.setFetchOperation("doFullTextSearch").
73 Isomorphic Software
SmartClient Quick Start
can create a variation of the fetch operation that returns limited fields like
so:
<operationBinding operationType="fetch"
operationId="comboBoxSearch"
outputs="name,title"/>
Setting outputs always limits the fields that are sent to the browser,
regardless of the type of DataSource used. With the built-in DataSources,
it also limits the fields requested from the underlying data store. Custom
DataSources or DMIs that want to similarly optimize communication with
the datastore can detect the requested outputs via
dsRequest.getOutputs() .
Declarative Security
The Declarative Security system allows you to attach role-based access
control to DataSource operations and DataSource fields, as well as create
a mix of authenticated and non-authenticated operations for applications
that support limited publicly-accessible functionality.
74 Isomorphic Software
SmartClient Quick Start
SmartClient Reference:
• Client Reference > Data Binding >
OperationBinding.requiresRole
• Client Reference > Data Binding >
DataSource.requiresAuthentication
• Client Reference > Data Binding >
DataSourceField.viewRequiresRole
75 Isomorphic Software
SmartClient Quick Start
• com.isomorphic.rpc.RPCManager.setAuthenticated()
• com.isomorphic.servlet IDACall
76 Isomorphic Software
SmartClient Quick Start
Non-Crud Operations
Some operations your application performs will not be "CRUD"
operations - meaning they do not fall into the standard Create,
Retrieve, Update, Delete pattern (called "add", "fetch", "update" and
"remove" in SmartClient). SmartClient provides a few ways to execute
such operations. The most convenient is simply to take an existing
DataSource and declare a "custom" operation, like
so:
<operationBinding operationType ="custom"
operationId="customOperationId">
... settings ...
</operationBinding>
When you declare a custom operation, it means that the input and
outputs of the operation are not constrained - they are not expected to
conform to the DataSource fields, and will not be subject to basic integrity
checks such as verifying that an "update" operation contains a value for
the primary key field.
77 Isomorphic Software
SmartClient Quick Start
Specifically, all the following use cases should not use custom operations:
78 Isomorphic Software
SmartClient Quick Start
References to objects in the template context have a prefix of ‘ $’, and dot
notation is used to access any property for which a standard Java Bean
“getter” method exists, or to access any value in a java.util.Map by its
key. For example, $httpSession.id retrieves the current sessionId via
HttpSession.getId() , and $dsRequest.criteria.myFieldName will retrieve
a criteria value for the field “myFieldName” via DSRequest.getCriteria(),
which returns a Map.
• Server-Assigned Criteria/Values
<criteria> and <values> tags allow you to modify the DSRequest
before execution. For example, when implementing something like
a “shopping cart,” the following declaration would force all items
added to the cart to be saved with the user’s current servlet
sessionId, and only allow the user to see his own items.
<operationBinding operationType="add">
<values fieldName="sessionId" value="$session.id"/>
</operationBinding>
<operationBinding operationType="fetch">
<criteria fieldName="sessionId" value="$session.id"/>
</operationBinding>
79 Isomorphic Software
SmartClient Quick Start
• Mail Templates
By adding a <mail> tag to any <operationBinding>, you can cause
an email to be sent if the operation completes successfully. A
Velocity expression is allowed for each attribute that configures
the email—to, from, subject, cc, and so on—as well as the message
template itself. This makes it very easy to send out notifications
when particular records are added or updated, or, with a “fetch”
operation, send emails to a list of recipients retrieved by the fetch.
• SQL/HQL Templating
When using SQLDataSource or HibernateDataSource in Power
Edition and above, Velocity expressions can be used to customize
generated SQL or replace it entirely. This is covered in its own
section, SQL Templating.
If you have additional data or methods you want to make available for
Velocity Expressions, you can add objects as attributes to the
servletRequest - these are accessible via
$servletRequest.getAttribute("attrName") (a shortcut of
requestAttributes.attrName also works). You can alternatively add your
own objects directly to the Velocity template context via
dsRequest.addToTemplateContext().
80 Isomorphic Software
SmartClient Quick Start
The Velocity template language can also call Java methods, create new
variables, even execute conditional logic or iterate over collections.
However, for any complex business logic, consider using Server Scripting
instead (described in the next section).
• SmartClient Reference:
Client Reference > Forms > Validator.serverCondition
• SmartClient Server Java Doc:
com.isomorphic.datasource.DSRequest.addToTemplateCont
ext()
Server Scripting
SmartClient allows you to embed "scriptlets" directly in your
.ds.xml file to take care of simple business logic without having to
create a separate file or class to hold the logic.
81 Isomorphic Software
SmartClient Quick Start
<DataSource...>
<script language="java">
if
(DataSource.isAdd(dsRequest.getOperationType())) {
dsRequest.setFieldValue("sessionId",
sessionId);
} else {
dsRequest.setCriteriaValue("sessionId",
sessionId);
return dsRequest.execute();
</script>
...
82 Isomorphic Software
SmartClient Quick Start
Note that scriptlets are only recompiled when you change them, so
will only be compiled once ever in the final deployment of your
application.
2. Scriptlets can easily be moved into normal .java files if they are
identified as reusable, become too large to manage in a .ds.xml
file, or if the (small) performance boost of compiling them to .class
files is desired. There is no need to translate from some other
language into Java
SmartClient Reference:
Concept> Server Script for SmartClient
83 Isomorphic Software
SmartClient Quick Start
<field includeFrom="stockItem.itemName"/>
In order for included fields to work, the foreignKey attribute must be used
to declare the relationship between the two DataSources. In this case,
there might be a field orderItem.stockItemId with
foreignKey="stockItem.id" ). Once relationships are declared, multiple
fields may be included from multiple different DataSources by simply
adding more includeFrom declarations.
84 Isomorphic Software
SmartClient Quick Start
SQL Templating
A DataSource declared with serverType=”sql” uses the SQLDataSource,
which automatically generates and executes SQL statements against a
database in response to DSRequests sent by the client.
The SQL generator in Power Edition can take the DSRequests generated by
DataBound components and automatically handle:
In contrast, the SQL Templating system lets you change small parts of the
generated SQL while leaving all the difficult, database-specific SQL up to
SmartClient. SQL Templating also allows you to take advantage of
database-specific features where appropriate, without losing automatic
SQL generation for standard features.
85 Isomorphic Software
SmartClient Quick Start
The following table summarizes the SQL statements that are generated
and how the DSRequest is used (note, these aren’t the actual statements –
additional SQL exists to handle data paging and database-specific quirks):
86 Isomorphic Software
SmartClient Quick Start
<operationBinding operationType="fetch"
operationId="outOfStock">
<tableClause>orderItem, stockItem</tableClause>
<whereClause>orderItem.stockItem_id == stockItem.id AND
stockItem.inStock == 'F' AND
$defaultWhereClause)</whereClause>
</operationBinding>
87 Isomorphic Software
SmartClient Quick Start
For the common case of incorporating a field from another table, declare
a field as usual with a <field> tag, then add the attribute
tableName="otherTable" . Setting tableName enables a field to be fetched
from another table and used in the WHERE clause, but automatically
excludes the field from the SQL for any operationType except “fetch.”
For example, given the orderItem and stockItem tables from the
preceding example, imagine stockItem had a column itemName that you
want to include in results from the orderItem DataSource.
<DataSource ID="orderItem" serverType="sql"
tableName="orderItem"
autoDeriveSchema="true">
<fields>
<field name="itemName" type="text"
tableName="stockItem"/>
</fields>
<operationBindings>
<operationBinding operationType="fetch">
<tableClause>orderItem, stockItem</tableClause>
<whereClause>orderItem.stockItem_id == stockItem.id AND
($defaultWhereClause)</whereClause>
</operationBinding>
</operationBindings>
</DataSource>
This approach can be extended to any number of fields from other tables.
88 Isomorphic Software
SmartClient Quick Start
In some cases, you may have several different Operation Bindings that use
different sets of added fields. In this case, you can set customSQL="true"
on the <field> element to turn off automatic generation. Then, use the
following <operationBinding> properties to control whether SQL is
generated for the field on a per-<operationBinding> basis.
Setting Meaning
customValueFields Comma-separated list of fields to allow in
SELECT clause despite being customSQL="true"
You can also define custom SQL on a per-field basis rather than a per-
clause basis using the following properties on a <field>:
Setting Meaning
customSelectExpression Expression to use in SELECT and WHERE clauses
customUpdateExpression Expression to use in SET clause of UPDATE
customInsertExpression Expression to use in VALUES clause of INSERT.
Defaults to customUpdateExpression
89 Isomorphic Software
SmartClient Quick Start
• Declarative
Far more compact than creating a Java class to hold equivalent
logic, and can be read and understood by people who would not be
able to read equivalent Java, such as QA engineers, UI engineers
or product managers with XML and SQL skills.
• Centralized
Security rules and other business rules appear right in the
business object definition, where they are more easily found.
90 Isomorphic Software
SmartClient Quick Start
• Secure
.ds.xml files are evaluated server-side, so all business rules
declared there are securely enforced. By driving client-side
behavior from secure server declarations, you avoid the common
error of implementing a business rule client-side only, and
forgetting to add server enforcement.
Custom DataSources
You can create a DataSource that calls existing business logic by simply
using DMI to declare what Java method to call for each operation. This is
a good approach if you have only a few DataSources, or while you are still
learning the basics.
91 Isomorphic Software
SmartClient Quick Start
92 Isomorphic Software
SmartClient Quick Start
SmartClient
server
DSRequest
DataSource
User action
operation
(eg ListGrid scrolled)
DSRequest
Other server
(JSON, XML,
SOAP)
Program action Server
Client
Data &
GUI (explicit method call) Services
SmartClient
server
RPCRequest
Generic RPC
RPCRequest
Other server
(any content)
RPC operations sent to the SmartClient Java Server can use DMI
declarations to route requests to appropriate server-side code, or a
custom servlet can interact with the server-side RPCManager class to
receive the RPCRequest.
examples/server_integration/custom_operations / shows
how to implement, call, and respond to generic RPCs with
the SmartClient Java Server
93 Isomorphic Software
SmartClient Quick Start
If you are using a WSDL-described web service, the operations of that web
service can be invoked either through DataSource binding (as described
under the heading WSDL Integration in the Data Integration chapter), or
can be invoked directly via webService.callOperation() . Invoking
callOperation() directly is much like an RPC operation, in that it allows
you to bypass the DataSource layer and retrieve data for custom
processing.
If you are not using a WSDL-described web service, you can retrieve the
raw HTTP response from a server (in JavaScript String form) by setting
the property serverOutputAsString on an RPCRequest. For an XML
response, you may then wish to use the facilities of the XMLTools class,
including the parseXML method, to process the response.
Responses that are valid JavaScript may be executed via the native
JavaScript method window.eval(), or can be executed automatically as
part of the RPC operation itself by setting rpcRequest.evalResult.
94 Isomorphic Software
SmartClient Quick Start
Client-side architecture
The SmartClient client-side system implements multiple layers of services
and components on top of standard web browsers:
95 Isomorphic Software
SmartClient Quick Start
Customized Themes
The first way to extend a SmartClient application is to change the overall
look-and-feel of the user interface. You can “re-skin” an application to
match corporate branding, to adhere to usability guidelines, or even to
personalize look & feel to individual user preferences.
The SmartClient SDK includes example themes (a.k.a. “skins”) for you to
explore. Use the Showcase to browse through each theme.
You can specify a different user interface theme in the header of your
SmartClient-enabled web pages:
96 Isomorphic Software
SmartClient Quick Start
The files for all available SmartClient user interface themes are located in
the /isomorphic/skins directory. Each theme provides three collections of
resources to specify look and feel:
Resource Contains
skin_styles.css a collection of CSS styles that are applied to
parts of visual components in various states
(e.g. cellSelectedOver for a selected cell in
a grid with mouse-over highlighting)
images/ a collection of small images that are used as
parts of visual components when CSS
styling is not sufficient (e.g.
TreeGrid/folder_closed.gif)
isc.Page.setSkinDir("[ISOMORPHIC]/skins/SmartClient/")
isc.Page.setSkinDir("[ISOMORPHIC]/skins/BrushedMetal/")
97 Isomorphic Software
SmartClient Quick Start
Customized Components
The easiest way to extend the SmartClient component set is to subclass
and customize existing components.
For example, let’s say you want a customized button component that
draws bigger, bolder buttons. The standard SmartClient Button
component has a size of 100 by 20 pixels, a non-wrapping title, and
styling based on CSS style names that begin with “button.” So this code:
isc.Button.create({title:"standard button title"});
98 Isomorphic Software
SmartClient Quick Start
New Components
If you need to extend beyond the customizable properties of the standard
SmartClient component set, you can create entirely new components.
99 Isomorphic Software
SmartClient Quick Start
These examples are your best starting points for building new
SmartClient components.
Create a Canvas subclass that contains your own HTML and CSS
template code.
http://www.smartclient.com/index.jsp#ne
stedEditor
11. Tips
Beginner Tips
If this is not possible, just use the HTML5 DOCTYPE for all
versions of Internet Explorer.
Architecture Tips
o component layout
o view navigation
For web applications that are deployed over slow WAN, dial-up, or
cellular links, you may want to integrate the optional Network
Performance module. This SmartClient module provides explicit
caching control, as well as server-side file packaging and
compression services, for optimal performance on slow networks.
However, it does take time and memory to create and draw all of
those components on the client. For immediate responsiveness,
you will want to create and draw only the components required for
If you are stuck with a data model involving multiple primary keys
and you need to use a feature that doesn't support multiple
primary keys, you can use a "synthetic" primary key: declare a
single primary key in your DataSource, then generate values for
this field by combining the values of the primary key fields in the
underlying data store.
This chapter offers advice for the most effective approaches to use when
evaluating Smart Client for use in your project or product.
In contrast, if you were to evaluate using the LGPL edition and implement
REST-based integration, upon purchasing a license you will immediately
want to switch to the more powerful, pre-built server integration instead,
which also provides access to all server-based features. In this scenario
you will have wasted time building a REST connector during evaluation
and given yourself a false perception of the learning curve and effort
involved in using SmartClient.
Evaluating Performance
SmartClient is the highest performance platform available for web
applications, and you can easily confirm this during your evaluation.
Unlike many web sites, web applications are visited repeatedly by the
same users on a frequent basis, and users will spend significant time
actually using the application.
For example, in many different types of applications a user will search for
a specific record, view the details of that record, modify that record or
related data, and repeat this pattern many times within a given session.
With the correct performance testing approach in hand, you are ready to
correctly assess the performance of SmartClient. If you have followed
SmartClient best practices, you application will show a drastic reduction
in dynamic requests due to features like:
DataSource.cacheAllData documentation
Consider, for example, the long term cost of recreating any single feature
from the Pro product:
If you are a developer and you recognize that the features in Pro could
save you time, you may find that an argument firmly based on cost
savings and ROI (Return On Investment) will enable you to work with
cutting edge technology and save you from wasting time “re-inventing the
wheel.”
As with any open source project, patches and contributions are always
welcome. However, as a professionally employed developer, the best way
to support the free product is to fuel further innovation by purchasing
licenses, support, and other services.
Contacts
Web smartclient.com
General info@smartclient.com
feedback@smartclient.com
Licensing sales@smartclient.com
End of Guide