Inspite of all the trials and error, I could not run the sample application. Any help in this will be of great help to a newbie like me.
In order to use smartGWTEE feature, I created a db interaction and CRUD sample as per the guidelines given in EE showcase.
I created a standard project gwt web application.
Copied all files from WEB-INF/lib directory of the smartGWTEE > showcase demo > lib to myproject WEB-INF/lib.
Copied the server.properties from the showcase to myproject and changed relavant things.
### Here is my code ###
src > crud > client > ds > countries.ds.xml :
src > crud > Gtlcrud.gwt.xml :
src > server.properties :
please refer to next part for some more details, this post has exceeded 10000 chars :)
In order to use smartGWTEE feature, I created a db interaction and CRUD sample as per the guidelines given in EE showcase.
I created a standard project gwt web application.
Copied all files from WEB-INF/lib directory of the smartGWTEE > showcase demo > lib to myproject WEB-INF/lib.
Copied the server.properties from the showcase to myproject and changed relavant things.
### Here is my code ###
src > crud > client > ds > countries.ds.xml :
Code:
<!-- Auto-generated from database table countries --> <DataSource dbName="zoe" tableName="countries" ID="countries" dataSourceVersion="1" generatedBy="7.1a/Enterprise Development Only 2009-06-24" serverType="sql" > <fields> <field primaryKey="true" name="countriesid" type="sequence"></field> <field name="insertby" length="50" type="text"></field> <field name="updateby" length="50" type="text"></field> <field name="inserttime" type="date"></field> <field name="updatetime" type="date"></field> <field name="countrycode" length="3" type="text"></field> <field name="countryname" length="100" type="text"></field> </fields> </DataSource>
Code:
package gtl.crud.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VStack; import com.smartgwt.client.widgets.viewer.DetailViewer; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class Gtlcrud implements EntryPoint { public void onModuleLoad() { DataSource dataSource = DataSource.get("countries"); VStack vStack = new VStack(); vStack.setLeft(175); vStack.setTop(75); vStack.setWidth("70%"); vStack.setMembersMargin(20); Label label = new Label(); label.setContents("<ul>" + "<li>click a record in the grid to view and edit that record in the form</li>" + "<li>click <b>Save</b> to save changes to an edited record in the form</li>" + "<li>click <b>Clear</b> to clear all fields in the form</li>" + "<li>enter text like \"board\" in the Item field and click <b>Filter</b> to filter (substring match) the grid based on the value Item form value only.</li>" + "<li>select a row and click <b>Fetch</b> to fetch records (exact match) for the grid based on the value of the 'Item' form value only.</li>" + "<li>click <b>Delete</b> to delete all selected records</li>" + "<li>double-click a record in the grid to edit inline (press Return, or arrow/tab to another record, to save)</li>" + "</ul>"); vStack.addMember(label); // databound ListGrid // * click records to edit in boundForm and view in boundViewer // * double-click record to edit inline (Return or arrow/tab off current row to save) final ListGrid boundList = new ListGrid(); boundList.setDataSource(dataSource); boundList.setHeight(200); boundList.setCanEdit(true); vStack.addMember(boundList); final DynamicForm boundForm = new DynamicForm(); boundForm.setDataSource(dataSource); boundForm.setNumCols(4); boundForm.setAutoFocus(false); vStack.addMember(boundForm); HLayout toolbar = new HLayout(); toolbar.setMembersMargin(10); toolbar.setHeight(22); final IButton saveBtn = new IButton("Save"); saveBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boundForm.saveData(); if (!boundForm.hasErrors()) { boundForm.clearValues(); saveBtn.disable(); } } }); toolbar.addMember(saveBtn); final IButton newBtn = new IButton("New"); newBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boundForm.editNewRecord(); saveBtn.enable(); } }); toolbar.addMember(newBtn); IButton clearBtn = new IButton("Clear"); clearBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boundForm.clearValues(); saveBtn.disable(); } }); toolbar.addMember(clearBtn); IButton filterBtn = new IButton("Filter"); filterBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boundList.filterData(boundForm.getValuesAsCriteria()); saveBtn.disable(); } }); toolbar.addMember(filterBtn); IButton fetchBtn = new IButton("Fetch"); fetchBtn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { boundList.fetchData(boundForm.getValuesAsCriteria()); saveBtn.disable(); } }); toolbar.addMember(fetchBtn); vStack.addMember(toolbar); final DetailViewer boundViewer = new DetailViewer(); boundViewer.setDataSource(dataSource); vStack.addMember(boundViewer); boundList.addRecordClickHandler(new RecordClickHandler() { public void onRecordClick(RecordClickEvent event) { Record record = event.getRecord(); boundForm.editRecord(record); saveBtn.enable(); boundViewer.viewSelectedData(boundList); } }); boundList.filterData(new Criteria()); vStack.draw(); } }
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd"> <module rename-to='gtlcrud'> <!-- 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.smartgwt.SmartGwt"/> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- Other module inherits --> <!-- Specify the app entry point class. --> <entry-point class='gtl.crud.client.Gtlcrud'/> </module>
src > server.properties :
Code:
webRoot: __AUTODETECT__ isomorphicPathRootRelative: gtlcrud/sc apps.adminConsole.location: $webRoot/gtlcrud/tools ui.adminConsole.location: $webRoot/gtlcrud/tools sql.defaultDatabase: Mysql # -------------- 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 sql.Mysql.driver: com.mysql.jdbc.Driver # name of the database to use sql.Mysql.driver.databaseName: ns # 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:root # -------------- 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:gtl/crud/client/ds project.ui: $webRoot/shared/ui project.apps: $webRoot/shared/app RPCManager.enabledBuiltinMethods: *
Comment