Hi !
I can’t run the project below.
Apparently, the function
listGrid.setDataSource(DataSource.get("ormDataSource_country"));
can’t find the datasource. I made the recommended checks:
Bad filesystem paths in gold server.properties bad DataSource. ds.xml file.
My filesystem looks ok. Thank you to tell me if you see errors in server.properties.
Tell me if you need more infos, or more files.
Thanks !
Tipi_v1.java:
package com.tipi_v1.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.smartgwt.client.types.FetchMode;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.VLayout;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class tipi_v1 implements EntryPoint {
public final RootPanel rootPanel = RootPanel.get();
public VerticalPanel screen = null;
private static tipi_v1 instance = null;
public static tipi_v1 getInstance(){
if(null == instance) {
instance = new tipi_v1();
}
return instance;
}
/**
* Entry point method
*/
public void onModuleLoad() {
final ListGrid listGrid = new ListGrid();
listGrid.setWidth(700);
listGrid.setHeight(224);
listGrid.setAlternateRecordStyles(true);
listGrid.setDataSource(DataSource.get("ormDataSource_country"));
listGrid.setCanEdit(true);
listGrid.setCanRemoveRecords(true);
listGrid.setDataFetchMode(FetchMode.LOCAL);
listGrid.setAutoFetchData(true);
listGrid.setUseAllDataSourceFields(true);
IButton newButton = new IButton("Add New");
newButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
listGrid.startEditingNew();
}
});
VLayout layout = new VLayout(15);
layout.addMember(listGrid);
layout.addMember(newButton);
layout.draw();
}
ormDataSource_country.ds.xml:
<DataSource
ID="ormDataSource_country"
serverConstructor="com.smartgwt.sample.showcase.server.customDataSource.ORMDataSource"
mappedBeanClass="com.smartgwt.sample.showcase.server.customDataSource.Country"
>
<fields>
<field name="pk" type="sequence" hidden="true" primaryKey="true" />
<field name="countryCode" type="text" title="Code" required="true" />
<field name="countryName" type="text" title="Country" required="true" />
<field name="capital" type="text" title="Capital" />
<field name="area" type="float" title="Area (km²)" />
<field name="population" type="integer" title="Population" />
<field name="gdp" type="float" title="GDP ($M)" />
</fields>
</DataSource>
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__
# 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: tipi_v1/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/tipi_fk
# 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/ds
project.ui: $webRoot/shared/ui
project.apps: $webRoot/shared/app
# SECURITY NOTE: Do not deploy applications with all builtin RPCs enabled. Some of these are
# development-only tools that have not been audited from a security standpoint.
#
# The special '*' value enables all builtin RPCs. xmlToJS and uploadProgressCheck are meant
# for production deployment, others have not been audited. For more information, see the
# "Deploying SmartClient" topic in the ReferenceDocs.
#for development
RPCManager.enabledBuiltinMethods: *
#RPCManager.enabledBuiltinMethods: xmlToJS, uploadProgressCheck
#===============================================================================
# JPA subsystem
#===============================================================================
# According to JPA specifications only simple class name can be used in queries.
# Some providers follows these specs strictly (for example EclipseLink).
# Some providers allows using fully-qualified class name usage (for example Hibernate, Datanucleus).
# Setting defaluts to false - simple class name usage.
# To resolve class name collisions this setting can be set to true
# (should be used with provider supporting fully-qualified class name usage).
#jpa.useQualifiedClassName: true
# Default EMF provider implementation (implements EMFProviderInterface).
# Fully qualified class name.
# Existing implementations:
# com.isomorphic.jpa.EMFProviderLMT - for Locally Managed Transactions (LMT)
# com.isomorphic.jpa.EMFProviderNoTransactions - no transactions support
# com.isomorphic.jpa.EMFProviderCMT - for Container Managed Transactions (CMT)
jpa.emfProvider: com.isomorphic.jpa.EMFProviderLMT
# Settings for LMT type
# Name of the datasource
jpa.persistenceUnitName: ds
# Resource references for CMT type
# EntityManager resource reference name declared in /WEB-INF/web.xml.
# Example declaration:
# <persistence-context-ref>
# <persistence-context-ref-name>persistence/em</persistence-context-ref-name>
# <persistence-unit-name>PERSISTENCE_UNIT_NAME</persistence-unit-name>
# </persistence-context-ref>
jpa.cmt.entityManager: persistence/em
# Transaction resource reference name declared in /WEB-INF/web.xml.
# Example declaration:
# <resource-env-ref>
# <resource-env-ref-name>persistence/tx</resource-env-ref-name>
# <resource-env-ref-type>javax.transaction.UserTransaction</resource-env-ref-type>
# </resource-env-ref>
jpa.cmt.transaction: persistence/tx
Tipi_v1.html
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="Tipi_v1.css">
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>TiPi</title>
<!-- -->
<!-- This script loads your compiled module. -->
<!-- If you add any GWT meta tags, they must -->
<!-- be added before this line. -->
<!-- -->
<script>
var isomorphicDir = "tipi_v1/sc/";
</script>
<script type="text/javascript" language="javascript" src="tipi_v1/tipi_v1.nocache.js"></script>
</head>
<!-- -->
<!-- The body can have arbitrary html, or -->
<!-- you can leave the body empty if you want -->
<!-- to create a completely dynamic UI. -->
<!-- -->
<body>
<div id="container">
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<noscript>
<!--load datasources from server -->
<script src="sc/DataSourceLoader?dataSource=ormDataSource_country"></script>
<!-- history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
Your web browser must have JavaScript enabled
in order for this application to display correctly.
</div>
</noscript>
<table id="connect_tab">
<tr>
<td id="loginFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
</table>
</div>
</body>
</html>
For info, i’m using:
- SmartGWT EE 2.4 Evaluation
- Firefox 4.01