Hi there
I'm still quite new to Smart Client and I need to build a simple proof of concept application using a couple of different technologies. Due to some restrictions I cannot use JSP pages and must utilise pure HTML pages.
Alot of what I'm doing is based on the examples so I'm problably only have a small mistake.
My HTML page
My handler class that should handle all the requests that gets sent to the server
My data source file on the server
The problem.
The communication between the server and the client is not working properly while debugging when you try to fetch the data the data gets retrieved from the database but it never gets populated in either the grid or the form. further when you try and Save any new data the save / add method is never called only the fetch method.
Another thing that I have not yet seen how to do is one of my pages I am to develop is going to define the items for a dropdown box on another form, I would need to be able to retrieve all the items and dynamically populate the dropdown box further I'd need to associate the value to a key.
Please say if you need any further information.
I'm still quite new to Smart Client and I need to build a simple proof of concept application using a couple of different technologies. Due to some restrictions I cannot use JSP pages and must utilise pure HTML pages.
Alot of what I'm doing is based on the examples so I'm problably only have a small mistake.
My HTML page
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> <html> <head> </head> <body> <script>window.isomorphicDir='../../YAPoC2/isomorphic/';</script> <script src="isomorphic/system/modules/ISC_Core.js?isc_version=5.6.js"></script><script>isc._lastModule='Core';</script> <script src="isomorphic/system/modules/ISC_Foundation.js?isc_version=5.6.js"></script><script>isc._lastModule='Foundation';</script> <SCRIPT SRC="isomorphic/system/modules/ISC_DataBinding.js?isc_version=5.6.js"></SCRIPT><SCRIPT>isc._lastModule='DataBinding';</SCRIPT> <script src="isomorphic/system/modules/ISC_Containers.js?isc_version=5.6.js"></script><script>isc._lastModule='Containers';</script> <script src="isomorphic/system/modules/ISC_Grids.js?isc_version=5.6.js"></script><script>isc._lastModule='Grids';</script> <script src="isomorphic/system/modules/ISC_Forms.js?isc_version=5.6.js"></script><script>isc._lastModule='Forms';</script> <script src="isomorphic/system/modules/ISC_DataBinding.js?isc_version=5.6.js"></script><script>isc._lastModule='DataBinding';</script> <script src="isomorphic/skins/SmartClient/load_skin.js?isc_version=5.6.js"></script> <span wicket:id = "navomaticBorder"> <script> isc.DataSource.create({ ID:"supplyItemDMI", serverType:"generic", // operationBindings:[ // {operationType:"fetch", serverMethod:"fetch"}, // {operationType:"add", serverMethod:"add"}, // {operationType:"update", serverMethod:"update"}, // {operationType:"remove", serverMethod:"remove"} // ], fields:{ ID:{ type:"text", name:"ID", length:45, hidden:true, primaryKey:true }, Name:{ type:"text", title:"Name", name:"name", length:120, }, Address:{ type:"text", title:"Address", name:"Address", length:255, }, Age:{type:"Integer", title:"Age", name:"Age"}, Sex:{type:"Integer", title:"Gender", name:"Sex"}, DeletedFlag:{ type:"Integer", name:"DeletedFlag", hidden:true } } }) VStack.create({ left:50, top:75, width:"70%", membersMargin:20, members:[ // databound DetailViewer // * click boundList records to display DetailViewer.create({ ID:"boundViewer", autoDraw: false, dataSource: supplyItemDMI }), // 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) ListGrid.create({ ID:"boundList", autoDraw: false, dataSource: supplyItemDMI, height:200, canEdit:true, selectionChanged : function (record, state) { if (this.selection.anySelected()) { deleteBtn.enable(); saveBtn.setDisabled(this.selection.multipleSelected()); boundForm.editRecord(record); boundViewer.viewSelectedData(this); } else { deleteBtn.disable(); saveBtn.disable(); } } }), // databound DynamicForm // * click boundList records to edit DynamicForm.create({ ID:"boundForm", autoDraw: false, dataSource: supplyItemDMI, numCols:"6", autoFocus:false }), // toolbar to perform various actions using the boundForm values (see helpText above) Toolbar.create({ autoDraw:false, membersMargin:10, buttonConstructor: "IButton", height: 22, buttons:[ {title:"Save", click:"boundForm.saveData()", ID:"saveBtn"}, {title:"Clear", click:"boundForm.clearValues();boundForm.editNewRecord();saveBtn.enable()"}, {title:"Filter", click:"boundList.filterData(boundForm.getValuesAsCriteria());"}, {title:"Fetch", click:"boundList.fetchData(boundForm.getValuesAsCriteria());"}, {title:"Delete", ID:"deleteBtn", disabled: true, click:"boundList.removeSelectedData();boundList.deselectAllRecords()"} ] }) ] }); boundList.fetchData(); </script> </span> </body> </html>
Code:
package com.stracienta.handlers; import java.io.*; import java.util.*; import com.isomorphic.util.DataTools; import com.isomorphic.datasource.*; import com.isomorphic.util.ErrorReport; import com.stracienta.PoC.persistenceObjects.SalesRepItem; import com.stracienta.PoC.businessLogic.*; public class SalesRepHandler { private ThinLogicLayer logicLayer = null; public SalesRepHandler () { logicLayer = new ThinLogicLayer(); } public DSResponse fetch(DSRequest dsRequest) throws Exception { DSResponse dsResponse = new DSResponse(); List<SalesRepItem> list = logicLayer.getSalesRep(); dsResponse.setStartRow(0); dsResponse.setEndRow(list.size()); dsResponse.setData(list); return dsResponse; } public SalesRepItem add(SalesRepItem item) throws Exception { logicLayer.addSalesRep(item); return item; } public SalesRepItem update(SalesRepItem item) throws Exception { logicLayer.updateSalesRep(item); return item; } public SalesRepItem remove(SalesRepItem item) throws Exception { logicLayer.remove(item); return item; } }
Code:
<DataSource ID="supplyItemDMI" serverType="generic" testFileName="supplyItem.data.xml" > <fields> private String id; private String name; private String address; private int age; private int sex; private int deletedflag; <field name="id" type="sequence" hidden="true" primaryKey="true"/> <field name="iname" type="text" title="Name" length="120" required="true"/> <field name="address" type="text" title="Address" length="255" required="true"/> <field name="age" type="integer" title="Age" required="true"/> <field name="sex" type="integer" title="Gender" required="true"/> <field name="deletedflag" type="integer" hidden="true"/> </fields> <serverObject lookupStyle="new" className="com.stracienta.handlers.SalesRepHandler"/> <!-- You can define an operationBindings section to bind operation names to server method (potentially additionally discriminated by the operationId). In the absense of this section, the server will look for a server method named after the operationType. --> <operationBindings> <binding operationType="fetch" serverMethod="fetch"> <serverObject lookupStyle="new" className="com.stracienta.handlers.SalesRepHandler"/> </binding> <binding operationType="add" serverMethod="add"> <serverObject lookupStyle="new" className="com.stracienta.handlers.SalesRepHandler"/> </binding> </operationBindings> </DataSource>
The communication between the server and the client is not working properly while debugging when you try to fetch the data the data gets retrieved from the database but it never gets populated in either the grid or the form. further when you try and Save any new data the save / add method is never called only the fetch method.
Another thing that I have not yet seen how to do is one of my pages I am to develop is going to define the items for a dropdown box on another form, I would need to be able to retrieve all the items and dynamically populate the dropdown box further I'd need to associate the value to a key.
Please say if you need any further information.
Comment