Hi Isomorphic,
it turns out that this is not working as expected in all cases.
Testcase (using v10.1p_2016-04-21):
supplyItem.ds.xml:
BuiltInDS.java:
supplyItemTest.csv:
This is an important one for me.
Best regards
Blama
it turns out that this is not working as expected in all cases.
- The in memory unique validation is also done for required="false" fields (see description-field in the testcase)
- The normal unique validation against the DB is not done (search the server-log for "Desc B", which is one of the descriptions in the test csv-file. There is not SQL with it as search value)
Testcase (using v10.1p_2016-04-21):
supplyItem.ds.xml:
Code:
<DataSource xmlns="lmscompany/ds" ID="supplyItem" serverType="sql" tableName="supplyItem" titleField="itemName" testFileName="/examples/shared/ds/test_data/supplyItem.data.xml" dbImportFileName="/examples/shared/ds/test_data/supplyItemLarge.data.xml" > <fields> <field name="itemID" type="sequence" hidden="true" primaryKey="true"/> <field name="itemName" type="text" title="Item" length="128" required="true"/> <field name="SKU" type="text" title="SKU" length="10" required="true"/> <field name="description" type="text" title="Description" length="2000"> <validators> <validator type="isUnique" /> </validators> </field> <field name="category" type="text" title="Category" length="128" required="true" foreignKey="supplyCategory.categoryName"/> <field name="units" type="enum" title="Units" length="5"> <valueMap> <value>Roll</value> <value>Ea</value> <value>Pkt</value> <value>Set</value> <value>Tube</value> <value>Pad</value> <value>Ream</value> <value>Tin</value> <value>Bag</value> <value>Ctn</value> <value>Box</value> </valueMap> </field> <field name="unitCost" type="float" title="Unit Cost" required="true"> <validators> <validator type="floatRange" min="0" errorMessage="Please enter a valid (positive) cost"/> <validator type="floatPrecision" precision="2" errorMessage="The maximum allowed precision is 2"/> </validators> </field> <field name="inStock" type="boolean" title="In Stock"/> <field name="nextShipment" type="date" title="Next Shipment"/> </fields> </DataSource>
Code:
package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.Version; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.BatchUploader; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.ImgButton; import com.smartgwt.client.widgets.Window; 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.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.CellOutEvent; import com.smartgwt.client.widgets.grid.events.CellOutHandler; import com.smartgwt.client.widgets.grid.events.CellOverEvent; import com.smartgwt.client.widgets.grid.events.CellOverHandler; import com.smartgwt.client.widgets.grid.events.RowOutEvent; import com.smartgwt.client.widgets.grid.events.RowOutHandler; import com.smartgwt.client.widgets.grid.events.RowOverEvent; import com.smartgwt.client.widgets.grid.events.RowOverHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { private VLayout mainLayout; private IButton recreateBtn; public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); mainLayout = new VLayout(20); mainLayout.setWidth100(); mainLayout.setHeight100(); recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")"); w.setTitle("TITLE" + w.getTitle()); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); final BatchUploader bu = new BatchUploader(); bu.setUploadDataSource(DataSource.get("supplyItem")); w.addItem(bu); w.show(); } }[B][/B]
supplyItemTest.csv:
Code:
"nextShipment","category","itemName","itemID","unitCost","description","SKU","inStock","units" "2009-01-21","Audio","Small grey widget",,0.41,"Desc A","545315","","Ea" "2009-01-21","Audio","Large grey widget",,0.41,"Desc A","45300","","EACH" "2008-11-17","Pencils","Small blue gizmo",,-0.47,"Desc B","90600","","Ea" "","Waste Bins","Large green gizmo",,0.61,"Desc C","135900","","Packet" "","String","Small red widget",,0.58,"","190000","","Ea" "2014-11-17","String","Small piece of string",,0.22,"","90600","","Ea" "2012-03-11","String","More string",,0.58,"","1900111","","Roll" [B][/B]
This is an important one for me.
Best regards
Blama
Comment