<REPOSTED FROM SmartClient forum because no one answers posts in that forum. Why the two forums?>
I'm using smartclient EE version 2.4 and Chrome (also Firefox) with the Eclipse Plugin on Ubuntu 10.10. I'm still having problems with HTTP 403 errors in loading the xml file for the datasource.
I am storing the xml file in /war/shared/ds/ but the web server says it doesn't have access to this directory. This is not a local problem in that it also complains when I deploy the app to my website.
Is there an example of a FULL AND INTACT eclipse project file system? I can't find any information on how files are to be laid out. It seems like this is a major headache as the whole system is sensitive to where files are put.
I'm posting all of the config files that I can find and where they are. I mainly borrowed these from showcase examples but I really don't know if they are in the correct place or not.
=====================================================
From the Developer Console:
01:09:18.107 [ERROR] [SmartaskWeb] 01:09:18.104:XRP7:WARN:RPCManager:Transport error - HTTP code: 403 for URL: http://127.0.0.1:8888/SmartaskWeb/shared/ds/, response: {operationId: "tasklistDS_fetch",
clientContext: Obj,
context: Obj,
transactionNum: 0,
httpResponseCode: 403,
httpResponseText: "<html>\n<head>\n<meta http-equiv="Content-..."[1387],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: -90,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
data: "Transport error - HTTP code: 403 for URL..."[86],
__gwt_ObjectId: 498,
startRow: 0,
endRow: 0,
totalRows: 0}
com.smartgwt.client.core.JsObject$SGWT_WARN: 01:09:18.104:XRP7:WARN:RPCManager:Transport error - HTTP code: 403 for URL: http://127.0.0.1:8888/SmartaskWeb/shared/ds/, response: {operationId: "tasklistDS_fetch",
clientContext: Obj,
context: Obj,
transactionNum: 0,
httpResponseCode: 403,
httpResponseText: "<html>\n<head>\n<meta http-equiv="Content-..."[1387],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: -90,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
data: "Transport error - HTTP code: 403 for URL..."[86],
__gwt_ObjectId: 498,
startRow: 0,
endRow: 0,
totalRows: 0}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:636)
=================================
The response HTML:
===================================
[INFO] [SmartaskWeb] - TRANSPORT: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 403 FORBIDDEN</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /SmartaskWeb/shared/ds/. Reason:
<pre> FORBIDDEN</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
=============================================
/src/smartask/web/client/data/TasklistDS.java
=======================================================================
package smartask.web.client.data;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.events.ErrorEvent;
import com.smartgwt.client.data.events.HandleErrorHandler;
import com.smartgwt.client.data.fields.*;
import com.smartgwt.client.data.OperationBinding;
import com.smartgwt.client.rpc.HandleTransportErrorCallback;
import com.smartgwt.client.rpc.RPCManager;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.DSProtocol;
import smartask.web.client.SmartaskWeb;
public class TasklistDS extends DataSource {
private static TasklistDS instance = null;
public static TasklistDS getInstance() {
if (instance == null) {
instance = new TasklistDS("tasklistDS");
}
return instance;
}
public TasklistDS(String id) {
setID(id);
this.setPreventHTTPCaching(true);
if(SmartaskWeb.CLIENT)
{
setupClientOnlyMode();
}
else
{
setupServerMode();
}
setDataFields();
GWT.log("END DATA SOURCE CREATION");
}
private void setupClientOnlyMode()
{
GWT.log("Doing Client Mode...");
setClientOnly(true);
setDataURL("shared/ds/exampletask.xml");
//setRecordXPath("/task");
}
private void setupServerMode()
{
GWT.log("Doing Server Mode...");
setClientOnly(false);
setDataURL(GWT.getModuleBaseURL()+"shared/ds/");
setupBindOperations();
this.addHandleErrorHandler(new HandleErrorHandler(){
@Override
public void onHandleError(ErrorEvent event) {
GWT.log("DataSource: "+event.getResponse());
}
});
RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback(){
@Override
public void handleTransportError(int transactionNum, int status,
int httpResponseCode, String httpResponseText) {
GWT.log("TRANSPORT: " + httpResponseText);
}
});
}
private void setDataFields()
{
DataSourceTextField idField = new DataSourceTextField("id","Id");
idField.setPrimaryKey(true);
idField.setRequired(true);
idField.setCanEdit(false);
idField.setHidden(true);
DataSourceEnumField priorityField = new DataSourceEnumField("priority","Priority");
priorityField.setValueMap(new String[] {"high","medium","low"});
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
nameField.setRequired(true);
DataSourceTextField locationField = new DataSourceTextField("location", "Location");
DataSourceDateField dateField = new DataSourceDateField("duedatetime", "Due By");
DataSourceTextField tagsField = new DataSourceTextField("tags", "Tags");
DataSourceDateField remField = new DataSourceDateField("remdatetime", "Reminder");
DataSourceTextField noteField = new DataSourceTextField("notes", "Notes");
setFields(priorityField, idField, nameField,
dateField, locationField, tagsField, remField, noteField );
}
/* private void setURLPaths()
{
setFetchDataURL("ds/task_fetch_rest.xml");
setAddDataURL("ds/task_add_rest.xml");
setUpdateDataURL("ds/task_update_rest.xml");
setRemoveDataURL("ds/task_remove_rest.xml");
}*/
private void setupBindOperations()
{
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding add = new OperationBinding();
add.setOperationType(DSOperationType.ADD);
add.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding update = new OperationBinding();
update.setOperationType(DSOperationType.UPDATE);
update.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding remove = new OperationBinding();
remove.setOperationType(DSOperationType.REMOVE);
remove.setDataProtocol(DSProtocol.POSTMESSAGE);
setOperationBindings(fetch, add, update, remove);
}
}
=============================================================
/war/shared/ds/tasklistDS.ds.xml
=========================================================
<?xml version="1.0" encoding="UTF-8"?>
<DataSource ID="task">
<fields>
<field primaryKey="true" name="id" type="integer" hidden="true" required="true"/>
<field name="name" type="text" title="Name"/>
<field name="location" type="text" title="Location"/>
<field name="tags" type="text" title="Tags"/>
<field name="duedatetime" type="date" title="Due By"/>
<field name="remdatetime" type="date" title="Set Reminder" />
<field name="notes" type="text" title="Notes"/>
</fields>
</DataSource>
============================================================
/war/WEB-INF/web.xml
===============================================================
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- ISC init: initializes ISC framework -->
<servlet>
<servlet-name>Init</servlet-name>
<servlet-class>com.isomorphic.base.Init</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- The IDACall servlet handles all Built-in DataSource operations -->
<servlet>
<servlet-name>IDACall</servlet-name>
<servlet-class>com.isomorphic.servlet.IDACall</servlet-class>
</servlet>
<!-- RPCManager uses this URL by default for Built-in DataSource operations -->
<servlet-mapping>
<servlet-name>IDACall</servlet-name>
<url-pattern>/SmartaskWeb/sc/IDACall</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>IDACall</servlet-name>
<url-pattern>/SmartaskWeb/sc/IDACall/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>SmartaskWeb.html</welcome-file>
</welcome-file-list>
</web-app>
================================================================
/war/WEB-INF/appengine-web.xml
===========================================================================
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>smartaskcs552</application>
<version>1</version>
<!-- Configure serving/caching of GWT files -->
<static-files>
<include path="/index.jsp"/>
<include path="/SmartaskWeb.html"/>
<include path="/SmartaskWeb.css"/>
<include path="/favicon.ico" />
<include path="/images/**" />
<include path="/shared/ds/**"/>
<include path="/SmartaskWeb/**"/>
<exclude path="/SmartaskWeb/**.xml"/>
<exclude path="/SmartaskWeb/**.xsl"/>
<exclude path="/SmartaskWeb/**.wsdl"/>
</static-files>
<resource-files>
<include path="/src/**"/>
<include path="/shared/ds/**" />
<include path="/SmartaskWeb/shared/ds/**"/>
<include path="/SmartaskWeb/**.xml"/>
<include path="/SmartaskWeb/**.xsl"/>
<include path="/SmartaskWeb/**.wsdl"/>
</resource-files>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
=============================================================================
/src/server.properties
===============================================================================
# The webRoot directory:
# the directory that the servlet engine regards as the place where applications
# that use the servlet engine should be installed. Generally, it is safe to leave
# this at the default setting of __AUTODETECT__. When the SmartClient server is
# started, it logs a message to stdout telling you the autodetected path to your
# webRoot. If this path is not your actual webRoot, then you'll want to override
# this config parameter here.
#
# Valid values:
#
# 1. Absolute path to the webRoot directory
#
# 2. Special token: __AUTODETECT__
# When this token is used, SmartClient attempts to auto-detect the webRoot using
# standard servlet APIs. This may or may not work - depending on your
# container type and deployment type. For example, WAR/EAR deployments
# on some containers never make it to disk, and so the container refuses
# to provide the webRoot path.
#
# If SmartClient cannnot detect the webRoot, it sets the webRoot to
# __USE_CONTAINER__ (see below).
#
# 3. Special token: __USE_CONTAINER__
# When this token is used, SmartClient uses standard servet APIs for accessing
# filesystem resources. This is slower than direct file access and, since
# the servlet APIs provide no mechanism for writing to disk, means that some
# development tools like the FileAssembler will not work.
#
webRoot: __AUTODETECT__
# Set this to the GWT module name.
gwtModuleName: SmartaskWeb
# if you've moved the isomorphic directory from its default location in webRoot,
# set the root-relative path to it here
#
# For example, if in your deployment the 'isomorphic' dir is in /foo/bar, then set
# then you'll need to set this to foo/bar/isomorphic
isomorphicPathRootRelative: $gwtModuleName/sc
# -------------- PICK DATABASE TO USE --------------------
#
# The SmartClient SDK ships with examples that use a database as the persistence
# layer. By default, the SDK uses a built-in version of HSQLDB, but you can
# specify a different database to use here.
# which database do you want to use? HSQLDB is enabled by default.
sql.defaultDatabase: HSQLDB
# If you want to use Mysql instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: Mysql
# If you want to use Oracle instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: Oracle
# If you want to use Postgres instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: PostgreSQL
# If you want to use DB2 instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: DB2
# -------------- SETTINGS FOR HSQLDB --------------------
sql.HSQLDB.database.type: hsqldb
sql.HSQLDB.interface.type: driverManager
sql.HSQLDB.driver: org.hsqldb.jdbcDriver
sql.HSQLDB.driver.url: jdbc:hsqldb:hsql://localhost/isomorphic
# SQLServer
#----------
#sql.SQLServer.database.type: sqlserver
#sql.SQLServer.interface.type: driverManager
#sql.SQLServer.driver: com.microsoft.jdbc.sqlserver.SQLServerDriver
#sql.SQLServer.driver.url: jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind;User=sa;Password=
# DB2
#----
#sql.DB2.database.type: db2
#sql.DB2.interface.type: dataSource
# DataSource
#sql.DB2.driver: COM.ibm.db2.jdbc.DB2DataSource
#sql.DB2.driver.serverName: localhost
#sql.DB2.driver.databaseName: SAMPLE
#sql.DB2.driver.portNumber: 6789
#sql.DB2.driver.user: db2admin
#sql.DB2.driver.password: db2admin
# -------------- SETTINGS FOR MYSQL --------------------
# These are the settings for use with the Mysql database. If you have
# just done a fresh install of MySQL on the same machine where you are
# running your servlet engine, the values provided below will probably
# just work on most platforms.
# Configuration for Mysql Connector/J
#sql.Mysql.database.type: mysql
#sql.Mysql.database.ansiMode: false
#sql.Mysql.interface.type: dataSource
#sql.Mysql.driver: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
# name of the database to use
#sql.Mysql.driver.databaseName: isomorphic
# hostname and port where the database server is installed
#sql.Mysql.driver.serverName: localhost
#sql.Mysql.driver.portNumber: 3306
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; insert/update/replace/delete rows.
#sql.Mysql.driver.user: root
#sql.Mysql.driver.password:
# -------------- SETTINGS FOR ORACLE --------------------
# These are the settings for use with the Oracle database.
# hostname and port where the database server is installed
#sql.Oracle.driver.serverName: localhost
#sql.Oracle.driver.portNumber: 1521
# SID of Oracle Database
#sql.Oracle.driver.databaseName: isomorphic
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; create/drop sequences;
# insert/update/replace/delete rows.
#sql.Oracle.driver.user: system
#sql.Oracle.driver.password: manager
# -------------- SETTINGS FOR PostgreSQL --------------------
# These are the settings for use with the PostgreSQL database.
# hostname and port where the database server is installed
#sql.PostgreSQL.driver.serverName: localhost
#sql.PostgreSQL.driver.portNumber: 5432
# name of the database to use
#sql.PostgreSQL.driver.databaseName: isomorphic
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; create/drop sequences;
# insert/update/replace/delete rows.
#sql.PostgreSQL.driver.user: postgres
#sql.PostgreSQL.driver.password: test
# -------------- LOADING APP AND DATASOURCE DEFINITIONS --------------------
# Where the system looks for DataSource definition files ([dataSourceId].ds.xml or
# [dataSourceID].ds.js). It's useful to put all your DataSources in one
# directory since DataSources are frequently shared between applications.
# "project.datasources" is also where the DataSource Importer tool looks
# for available DataSources.
project.datasources=$webRoot/images
project.ui: $webRoot/shared/ui
project.apps: $webRoot/shared/app
# -------------- Other settings --------------------
# The setting RPCManager.enabledBuiltinMethods enables or disables the BuiltInRPCs - RPC calls
# that are built into the SmartClient Server. The setting below reflects the framework default
# of enabling only those RPCs that are typically needed in an application.
#
# See the JavaDoc for com.isomorphic.rpc.BuiltinRPC and com.isomorphic.tools.BuiltinRPC for all
# available builtinRPCs and their behavior.
#
# Note that many of the BuiltinRPCs are designed for use by tools such as Visual Builder, and
# provide services such as direct access to the file system (for load and save of screens) that
# would be unsafe to expose to untrusted users.
#
#RPCManager.enabledBuiltinMethods: xmlToJS, uploadProgressCheck, exportClientData, downloadClientExport, setAttributes
===================================================
/src/smartask/web/SmartaskWeb.gwt.xml
========================================
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='SmartaskWeb'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name="com.smartgwtee.SmartGwtEE"/>
<inherits name="com.smartgwtee.tools.Tools"/>
<!-- -->
<!-- inherits name=com.smartgwt.Gwt -->
<!-- <inherits name="com.smartgwt.SmartGwt"/>
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
-->
<!-- inherits name='com.smartclient.theme.silverwave.SilverWave' />
-->
<!-- Specify the app entry point class. -->
<entry-point class='smartask.web.client.SmartaskWeb'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
==============================
I'm using smartclient EE version 2.4 and Chrome (also Firefox) with the Eclipse Plugin on Ubuntu 10.10. I'm still having problems with HTTP 403 errors in loading the xml file for the datasource.
I am storing the xml file in /war/shared/ds/ but the web server says it doesn't have access to this directory. This is not a local problem in that it also complains when I deploy the app to my website.
Is there an example of a FULL AND INTACT eclipse project file system? I can't find any information on how files are to be laid out. It seems like this is a major headache as the whole system is sensitive to where files are put.
I'm posting all of the config files that I can find and where they are. I mainly borrowed these from showcase examples but I really don't know if they are in the correct place or not.
=====================================================
From the Developer Console:
01:09:18.107 [ERROR] [SmartaskWeb] 01:09:18.104:XRP7:WARN:RPCManager:Transport error - HTTP code: 403 for URL: http://127.0.0.1:8888/SmartaskWeb/shared/ds/, response: {operationId: "tasklistDS_fetch",
clientContext: Obj,
context: Obj,
transactionNum: 0,
httpResponseCode: 403,
httpResponseText: "<html>\n<head>\n<meta http-equiv="Content-..."[1387],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: -90,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
data: "Transport error - HTTP code: 403 for URL..."[86],
__gwt_ObjectId: 498,
startRow: 0,
endRow: 0,
totalRows: 0}
com.smartgwt.client.core.JsObject$SGWT_WARN: 01:09:18.104:XRP7:WARN:RPCManager:Transport error - HTTP code: 403 for URL: http://127.0.0.1:8888/SmartaskWeb/shared/ds/, response: {operationId: "tasklistDS_fetch",
clientContext: Obj,
context: Obj,
transactionNum: 0,
httpResponseCode: 403,
httpResponseText: "<html>\n<head>\n<meta http-equiv="Content-..."[1387],
xmlHttpRequest: [object XMLHttpRequest],
transport: "xmlHttpRequest",
status: -90,
clientOnly: undef,
httpHeaders: Obj,
isStructured: true,
callbackArgs: null,
results: Obj,
data: "Transport error - HTTP code: 403 for URL..."[86],
__gwt_ObjectId: 498,
startRow: 0,
endRow: 0,
totalRows: 0}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:636)
=================================
The response HTML:
===================================
[INFO] [SmartaskWeb] - TRANSPORT: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 403 FORBIDDEN</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /SmartaskWeb/shared/ds/. Reason:
<pre> FORBIDDEN</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
=============================================
/src/smartask/web/client/data/TasklistDS.java
=======================================================================
package smartask.web.client.data;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.events.ErrorEvent;
import com.smartgwt.client.data.events.HandleErrorHandler;
import com.smartgwt.client.data.fields.*;
import com.smartgwt.client.data.OperationBinding;
import com.smartgwt.client.rpc.HandleTransportErrorCallback;
import com.smartgwt.client.rpc.RPCManager;
import com.smartgwt.client.types.DSOperationType;
import com.smartgwt.client.types.DSProtocol;
import smartask.web.client.SmartaskWeb;
public class TasklistDS extends DataSource {
private static TasklistDS instance = null;
public static TasklistDS getInstance() {
if (instance == null) {
instance = new TasklistDS("tasklistDS");
}
return instance;
}
public TasklistDS(String id) {
setID(id);
this.setPreventHTTPCaching(true);
if(SmartaskWeb.CLIENT)
{
setupClientOnlyMode();
}
else
{
setupServerMode();
}
setDataFields();
GWT.log("END DATA SOURCE CREATION");
}
private void setupClientOnlyMode()
{
GWT.log("Doing Client Mode...");
setClientOnly(true);
setDataURL("shared/ds/exampletask.xml");
//setRecordXPath("/task");
}
private void setupServerMode()
{
GWT.log("Doing Server Mode...");
setClientOnly(false);
setDataURL(GWT.getModuleBaseURL()+"shared/ds/");
setupBindOperations();
this.addHandleErrorHandler(new HandleErrorHandler(){
@Override
public void onHandleError(ErrorEvent event) {
GWT.log("DataSource: "+event.getResponse());
}
});
RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback(){
@Override
public void handleTransportError(int transactionNum, int status,
int httpResponseCode, String httpResponseText) {
GWT.log("TRANSPORT: " + httpResponseText);
}
});
}
private void setDataFields()
{
DataSourceTextField idField = new DataSourceTextField("id","Id");
idField.setPrimaryKey(true);
idField.setRequired(true);
idField.setCanEdit(false);
idField.setHidden(true);
DataSourceEnumField priorityField = new DataSourceEnumField("priority","Priority");
priorityField.setValueMap(new String[] {"high","medium","low"});
DataSourceTextField nameField = new DataSourceTextField("name", "Name");
nameField.setRequired(true);
DataSourceTextField locationField = new DataSourceTextField("location", "Location");
DataSourceDateField dateField = new DataSourceDateField("duedatetime", "Due By");
DataSourceTextField tagsField = new DataSourceTextField("tags", "Tags");
DataSourceDateField remField = new DataSourceDateField("remdatetime", "Reminder");
DataSourceTextField noteField = new DataSourceTextField("notes", "Notes");
setFields(priorityField, idField, nameField,
dateField, locationField, tagsField, remField, noteField );
}
/* private void setURLPaths()
{
setFetchDataURL("ds/task_fetch_rest.xml");
setAddDataURL("ds/task_add_rest.xml");
setUpdateDataURL("ds/task_update_rest.xml");
setRemoveDataURL("ds/task_remove_rest.xml");
}*/
private void setupBindOperations()
{
OperationBinding fetch = new OperationBinding();
fetch.setOperationType(DSOperationType.FETCH);
fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding add = new OperationBinding();
add.setOperationType(DSOperationType.ADD);
add.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding update = new OperationBinding();
update.setOperationType(DSOperationType.UPDATE);
update.setDataProtocol(DSProtocol.POSTMESSAGE);
OperationBinding remove = new OperationBinding();
remove.setOperationType(DSOperationType.REMOVE);
remove.setDataProtocol(DSProtocol.POSTMESSAGE);
setOperationBindings(fetch, add, update, remove);
}
}
=============================================================
/war/shared/ds/tasklistDS.ds.xml
=========================================================
<?xml version="1.0" encoding="UTF-8"?>
<DataSource ID="task">
<fields>
<field primaryKey="true" name="id" type="integer" hidden="true" required="true"/>
<field name="name" type="text" title="Name"/>
<field name="location" type="text" title="Location"/>
<field name="tags" type="text" title="Tags"/>
<field name="duedatetime" type="date" title="Due By"/>
<field name="remdatetime" type="date" title="Set Reminder" />
<field name="notes" type="text" title="Notes"/>
</fields>
</DataSource>
============================================================
/war/WEB-INF/web.xml
===============================================================
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- ISC init: initializes ISC framework -->
<servlet>
<servlet-name>Init</servlet-name>
<servlet-class>com.isomorphic.base.Init</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- The IDACall servlet handles all Built-in DataSource operations -->
<servlet>
<servlet-name>IDACall</servlet-name>
<servlet-class>com.isomorphic.servlet.IDACall</servlet-class>
</servlet>
<!-- RPCManager uses this URL by default for Built-in DataSource operations -->
<servlet-mapping>
<servlet-name>IDACall</servlet-name>
<url-pattern>/SmartaskWeb/sc/IDACall</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>IDACall</servlet-name>
<url-pattern>/SmartaskWeb/sc/IDACall/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>SmartaskWeb.html</welcome-file>
</welcome-file-list>
</web-app>
================================================================
/war/WEB-INF/appengine-web.xml
===========================================================================
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>smartaskcs552</application>
<version>1</version>
<!-- Configure serving/caching of GWT files -->
<static-files>
<include path="/index.jsp"/>
<include path="/SmartaskWeb.html"/>
<include path="/SmartaskWeb.css"/>
<include path="/favicon.ico" />
<include path="/images/**" />
<include path="/shared/ds/**"/>
<include path="/SmartaskWeb/**"/>
<exclude path="/SmartaskWeb/**.xml"/>
<exclude path="/SmartaskWeb/**.xsl"/>
<exclude path="/SmartaskWeb/**.wsdl"/>
</static-files>
<resource-files>
<include path="/src/**"/>
<include path="/shared/ds/**" />
<include path="/SmartaskWeb/shared/ds/**"/>
<include path="/SmartaskWeb/**.xml"/>
<include path="/SmartaskWeb/**.xsl"/>
<include path="/SmartaskWeb/**.wsdl"/>
</resource-files>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
=============================================================================
/src/server.properties
===============================================================================
# The webRoot directory:
# the directory that the servlet engine regards as the place where applications
# that use the servlet engine should be installed. Generally, it is safe to leave
# this at the default setting of __AUTODETECT__. When the SmartClient server is
# started, it logs a message to stdout telling you the autodetected path to your
# webRoot. If this path is not your actual webRoot, then you'll want to override
# this config parameter here.
#
# Valid values:
#
# 1. Absolute path to the webRoot directory
#
# 2. Special token: __AUTODETECT__
# When this token is used, SmartClient attempts to auto-detect the webRoot using
# standard servlet APIs. This may or may not work - depending on your
# container type and deployment type. For example, WAR/EAR deployments
# on some containers never make it to disk, and so the container refuses
# to provide the webRoot path.
#
# If SmartClient cannnot detect the webRoot, it sets the webRoot to
# __USE_CONTAINER__ (see below).
#
# 3. Special token: __USE_CONTAINER__
# When this token is used, SmartClient uses standard servet APIs for accessing
# filesystem resources. This is slower than direct file access and, since
# the servlet APIs provide no mechanism for writing to disk, means that some
# development tools like the FileAssembler will not work.
#
webRoot: __AUTODETECT__
# Set this to the GWT module name.
gwtModuleName: SmartaskWeb
# if you've moved the isomorphic directory from its default location in webRoot,
# set the root-relative path to it here
#
# For example, if in your deployment the 'isomorphic' dir is in /foo/bar, then set
# then you'll need to set this to foo/bar/isomorphic
isomorphicPathRootRelative: $gwtModuleName/sc
# -------------- PICK DATABASE TO USE --------------------
#
# The SmartClient SDK ships with examples that use a database as the persistence
# layer. By default, the SDK uses a built-in version of HSQLDB, but you can
# specify a different database to use here.
# which database do you want to use? HSQLDB is enabled by default.
sql.defaultDatabase: HSQLDB
# If you want to use Mysql instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: Mysql
# If you want to use Oracle instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: Oracle
# If you want to use Postgres instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: PostgreSQL
# If you want to use DB2 instead, uncomment the following line
# and comment all other sql.defaultDatabase definitions
#sql.defaultDatabase: DB2
# -------------- SETTINGS FOR HSQLDB --------------------
sql.HSQLDB.database.type: hsqldb
sql.HSQLDB.interface.type: driverManager
sql.HSQLDB.driver: org.hsqldb.jdbcDriver
sql.HSQLDB.driver.url: jdbc:hsqldb:hsql://localhost/isomorphic
# SQLServer
#----------
#sql.SQLServer.database.type: sqlserver
#sql.SQLServer.interface.type: driverManager
#sql.SQLServer.driver: com.microsoft.jdbc.sqlserver.SQLServerDriver
#sql.SQLServer.driver.url: jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind;User=sa;Password=
# DB2
#----
#sql.DB2.database.type: db2
#sql.DB2.interface.type: dataSource
# DataSource
#sql.DB2.driver: COM.ibm.db2.jdbc.DB2DataSource
#sql.DB2.driver.serverName: localhost
#sql.DB2.driver.databaseName: SAMPLE
#sql.DB2.driver.portNumber: 6789
#sql.DB2.driver.user: db2admin
#sql.DB2.driver.password: db2admin
# -------------- SETTINGS FOR MYSQL --------------------
# These are the settings for use with the Mysql database. If you have
# just done a fresh install of MySQL on the same machine where you are
# running your servlet engine, the values provided below will probably
# just work on most platforms.
# Configuration for Mysql Connector/J
#sql.Mysql.database.type: mysql
#sql.Mysql.database.ansiMode: false
#sql.Mysql.interface.type: dataSource
#sql.Mysql.driver: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
# name of the database to use
#sql.Mysql.driver.databaseName: isomorphic
# hostname and port where the database server is installed
#sql.Mysql.driver.serverName: localhost
#sql.Mysql.driver.portNumber: 3306
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; insert/update/replace/delete rows.
#sql.Mysql.driver.user: root
#sql.Mysql.driver.password:
# -------------- SETTINGS FOR ORACLE --------------------
# These are the settings for use with the Oracle database.
# hostname and port where the database server is installed
#sql.Oracle.driver.serverName: localhost
#sql.Oracle.driver.portNumber: 1521
# SID of Oracle Database
#sql.Oracle.driver.databaseName: isomorphic
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; create/drop sequences;
# insert/update/replace/delete rows.
#sql.Oracle.driver.user: system
#sql.Oracle.driver.password: manager
# -------------- SETTINGS FOR PostgreSQL --------------------
# These are the settings for use with the PostgreSQL database.
# hostname and port where the database server is installed
#sql.PostgreSQL.driver.serverName: localhost
#sql.PostgreSQL.driver.portNumber: 5432
# name of the database to use
#sql.PostgreSQL.driver.databaseName: isomorphic
# username and password that can create and modify tables in that database
# this user must have the following privileges for the system to function
# properly: create/alter/drop table; create/drop sequences;
# insert/update/replace/delete rows.
#sql.PostgreSQL.driver.user: postgres
#sql.PostgreSQL.driver.password: test
# -------------- LOADING APP AND DATASOURCE DEFINITIONS --------------------
# Where the system looks for DataSource definition files ([dataSourceId].ds.xml or
# [dataSourceID].ds.js). It's useful to put all your DataSources in one
# directory since DataSources are frequently shared between applications.
# "project.datasources" is also where the DataSource Importer tool looks
# for available DataSources.
project.datasources=$webRoot/images
project.ui: $webRoot/shared/ui
project.apps: $webRoot/shared/app
# -------------- Other settings --------------------
# The setting RPCManager.enabledBuiltinMethods enables or disables the BuiltInRPCs - RPC calls
# that are built into the SmartClient Server. The setting below reflects the framework default
# of enabling only those RPCs that are typically needed in an application.
#
# See the JavaDoc for com.isomorphic.rpc.BuiltinRPC and com.isomorphic.tools.BuiltinRPC for all
# available builtinRPCs and their behavior.
#
# Note that many of the BuiltinRPCs are designed for use by tools such as Visual Builder, and
# provide services such as direct access to the file system (for load and save of screens) that
# would be unsafe to expose to untrusted users.
#
#RPCManager.enabledBuiltinMethods: xmlToJS, uploadProgressCheck, exportClientData, downloadClientExport, setAttributes
===================================================
/src/smartask/web/SmartaskWeb.gwt.xml
========================================
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='SmartaskWeb'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<inherits name="com.smartgwtee.SmartGwtEE"/>
<inherits name="com.smartgwtee.tools.Tools"/>
<!-- -->
<!-- inherits name=com.smartgwt.Gwt -->
<!-- <inherits name="com.smartgwt.SmartGwt"/>
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
-->
<!-- inherits name='com.smartclient.theme.silverwave.SilverWave' />
-->
<!-- Specify the app entry point class. -->
<entry-point class='smartask.web.client.SmartaskWeb'/>
<!-- Specify the paths for translatable code -->
<source path='client'/>
<source path='shared'/>
</module>
==============================
Comment