Hi SmartGwt gurus,
I'm hitting an issue setting the datasource ID when it's created from a XSD. This ID is needed to render the entity name in the RPC call to server:
Am I doing something wrong here?
Many thanks!
Regards,
Cheng
----
Here's the issue report:
1. the SmartGWT or SmartClient version and browser version(s) involved;
SmartGWT 2.2/2.4 - Chrome/FF - Win7
2. for a server-side problem, the complete logs generated during processing of the request;
N/A
3. for a client-side problem, the contents of the Developer Console (see FAQ for usage);
4. if there is a JavaScript error, the stack trace logged in the Developer Console (from Internet Explorer if possible); and
N/A
5. sample code.
I've only tweaked the XSD datasource example at showcase:
http://www.smartclient.com/smartgwt/showcase/#featured_xsd_ds
I'm pasting the code for conveniece. The line added is "schemaDS.setID("supplyItem");":
I'm hitting an issue setting the datasource ID when it's created from a XSD. This ID is needed to render the entity name in the RPC call to server:
Code:
<request> <data> <country> <---- here's where I use the ID <countryCode>A1</countryCode> <countryName>New Value</countryName> <capital>New Value</capital> <continent>New Value</continent> <area>45</area> <article>Article A1</article> <population>45</population> <member_g8>false</member_g8> <independence>2010-03-04T02:17:36</independence> <government>Despotism</government> </country> </data> <dataSource>country</dataSource> <operationType>add</operationType> <oldValues></oldValues> </request>
Many thanks!
Regards,
Cheng
----
Here's the issue report:
1. the SmartGWT or SmartClient version and browser version(s) involved;
SmartGWT 2.2/2.4 - Chrome/FF - Win7
2. for a server-side problem, the complete logs generated during processing of the request;
N/A
3. for a client-side problem, the contents of the Developer Console (see FAQ for usage);
Code:
00:18:44.418 [ERROR] [mybanners2] 00:18:44.408:XRP0:WARN:Log:java.lang.IllegalStateException: Cannot change configuration property 'ID' to supplyItem after the component has been created. com.smartgwt.client.core.JsObject$SGWT_WARN: 00:18:44.408:XRP0:WARN:Log:java.lang.IllegalStateException: Cannot change configuration property 'ID' to supplyItem after the component has been created. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 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:662)
N/A
5. sample code.
I've only tweaked the XSD datasource example at showcase:
http://www.smartclient.com/smartgwt/showcase/#featured_xsd_ds
I'm pasting the code for conveniece. The line added is "schemaDS.setID("supplyItem");":
Code:
package com.googlecode.mybanners.client; /* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.SchemaSet; import com.smartgwt.client.data.XMLTools; import com.smartgwt.client.data.XSDLoadCallback; import com.smartgwt.client.data.fields.DataSourceDateField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.util.KeyCallback; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.SC; 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.form.DynamicForm; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.layout.VLayout; public class XsdDataSourceSample implements EntryPoint { private VLayout layout; public void onModuleLoad() { if (!GWT.isScript()) { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new KeyCallback() { public void execute(String keyName) { SC.showConsole(); } }); } final ListGrid listGrid = new ListGrid(); listGrid.setCanEdit(true); final DynamicForm dynamicForm = new DynamicForm(); final IButton validateButton = new IButton("Validate"); validateButton.setDisabled(true); validateButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dynamicForm.validate(); } }); IButton loadButton = new IButton("Load Schema"); loadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { XMLTools.loadXMLSchema("schema/supplyItem.xsd", new XSDLoadCallback() { public void execute(SchemaSet schemaSet) { loadXMLSchemaReply(schemaSet, listGrid, dynamicForm, validateButton); } }); } }); layout = new VLayout(15); layout.addMember(loadButton); layout.addMember(listGrid); layout.addMember(dynamicForm); layout.addMember(validateButton); layout.draw(); } private void loadXMLSchemaReply(SchemaSet schemaSet, ListGrid listGrid, DynamicForm dynamicForm, IButton validateButton) { DataSource schemaDS = schemaSet.getSchema("supplyItem"); schemaDS.setID("supplyItem"); DataSource dataSource = new DataSource(); dataSource.setInheritsFrom(schemaDS); dataSource.setUseParentFieldOrder(true); DataSourceTextField itemID = new DataSourceTextField("itemId"); itemID.setHidden(true); itemID.setPrimaryKey(true); DataSourceTextField itemName = new DataSourceTextField("itemName", "item name"); DataSourceDateField nextShipment = new DataSourceDateField("nextShipment", "next shipment"); nextShipment.setUseTextField(true); dataSource.setFields(itemID, itemName, nextShipment); listGrid.setDataSource(dataSource); dynamicForm.setDataSource(dataSource); // to demonstrate grid editors, add sample data and start editing listGrid.setData(new ItemRecord[] { new ItemRecord(123, "Sample Item", "1091600", null, "Rollfix Glue", "Ea", 3.73, null, null) }); listGrid.startEditing(); // to demonstrate validation, use values that will fail validation dynamicForm.setValue("unitCost", -1.234); dynamicForm.setValue("SKU", "thisSkuIsWayTooLong"); validateButton.enable(); } }
Comment