We did add a feature where declaring type "text" on a field that has integer type for a *SQL* DataSource will force the value to int.
In older versions, setting a trivial valueXPath (same name as the bean getter method) would be one way to force conversion.
Announcement
Collapse
No announcement yet.
X
-
As you please :)
Code:<DataSource ID="Attachment" xmlFromConfig="true" beanClassName="com.aCompany.Attachment" dataSourceVersion="1" serverType="hibernate" autoDeriveSchema="false" dropExtraFields="true"> <fields> <field name="id" type="text" title="Id" primaryKey="true" detail="false"> </field> <field name="lastUpdated" type="date" title="Last Updated" detail="false" canView="true"> <validators> <Validator> <type>isDate</type> <typeCastValidator>true</typeCastValidator> </Validator> </validators> </field> <field name="dateCreated" type="date" title="Date Created" detail="false" canView="true"> <validators> <Validator> <type>isDate</type> <typeCastValidator>true</typeCastValidator> </Validator> </validators> </field> <field name="deleted" type="boolean" title="Deleted" detail="false" canView="true"> <validators> <Validator> <type>isBoolean</type> <typeCastValidator>true</typeCastValidator> <defaultErrorMessage></defaultErrorMessage> </Validator> </validators> </field> <field name="file" type="imageFile" title="File" detail="false" canFilter="false"></field> <field name="file_filename" type="text" title="File name" detail="true"></field> <field name="file_filesize" type="integer" title="File size" detail="true"></field> <field name="file_date_created" type="date" title="File date created" detail="true"></field> </fields> <allowAdvancedCriteria>true</allowAdvancedCriteria> <xmlFromConfig>true</xmlFromConfig> </DataSource>
Code:{ "actionURL":"http://localhost:8080/aCompany/gwt/com.aCompany.GWTModule/sc/IDACall", "showPrompt":true, "prompt":"Finding Records that match your criteria...", "transport":"xmlHttpRequest", "promptStyle":"cursor", "bypassCache":true, "data":{ "criteria":{ }, "operationConfig":{ "dataSource":"Attachment", "repo":null, "operationType":"fetch", "textMatchStyle":"substring" }, "startRow":0, "endRow":75, "componentId":"AttachmentGrid_4", "appID":"builtinApplication", "operation":"ref:Attachment_fetch", "oldValues":{ } } }
Code:{ dataSource:"Attachment", operationType:"fetch", componentId:"AttachmentGrid_4", data:{ }, startRow:0, endRow:75, textMatchStyle:"substring", resultSet:[ResultSet ID:isc_ResultSet_12 (created by: AttachmentGrid_4)], callback:{ caller:[ResultSet ID:isc_ResultSet_12 (created by: AttachmentGrid_4)], methodName:"fetchRemoteDataReply" }, willHandleError:true, showPrompt:true, prompt:"Finding Records that match your criteria...", oldValues:{ }, requestId:"Attachment$62716", clientContext:{ requestIndex:{ Class:"Number", formatter:"toString", localeStringFormatter:"toString", localeProperties:Obj } }, fallbackToEval:false, bypassCache:true }
Code:{ "operationId":"ref:Attachment_fetch", "transactionNum":14, "httpResponseCode":200, "transport":"xmlHttpRequest", "status":0, "httpHeaders":{ "Server":"Apache-Coyote/1.1", "Cache-Control":"no-cache", "Pragma":"no-cache", "Expires":"Tue, 10 Sep 2013 01:24:36 GMT", "Content-Type":"text/plain;charset=UTF-8", "Transfer-Encoding":"chunked", "Date":"Tue, 10 Sep 2013 01:24:37 GMT" }, "isStructured":true, "results":{ "data":[ { "file_filename":"Smartgwt.odt", "file_date_created":"2013-09-09", "lastUpdated":"2013-09-09", "deleted":false, "id":-614287573389057800, "dateCreated":"2013-09-09", "file_filesize":4992 }, { "file_filename":"Ultimate Guide to SmartGWT.webm", "file_date_created":"2013-09-09", "lastUpdated":"2013-09-09", "deleted":false, "id":458539461474260540, "dateCreated":"2013-09-09", "file_filesize":9214523 }, { "file_filename":"spring prob.txt", "file_date_created":"2013-09-10", "lastUpdated":"2013-09-10", "deleted":false, "id":5332552039815583000, "dateCreated":"2013-09-10", "file_filesize":7988 }, { "file_filename":"Clock.pdf", "file_date_created":"2013-09-10", "lastUpdated":"2013-09-10", "deleted":false, "id":5324327873266224000, "dateCreated":"2013-09-10", "file_filesize":7350 } ], "endRow":4, "invalidateCache":false, "isDSResponse":true, "operationType":"fetch", "queueStatus":0, "startRow":0, "status":0, "totalRows":4 }, "isDSResponse":true, "invalidateCache":false, "data":[ { "file_filename":"Smartgwt.odt", "file_date_created":"2013-09-09", "lastUpdated":"2013-09-09", "deleted":false, "id":-614287573389057800, "dateCreated":"2013-09-09", "file_filesize":4992 }, { "file_filename":"Ultimate Guide to SmartGWT.webm", "file_date_created":"2013-09-09", "lastUpdated":"2013-09-09", "deleted":false, "id":458539461474260540, "dateCreated":"2013-09-09", "file_filesize":9214523 }, { "file_filename":"spring prob.txt", "file_date_created":"2013-09-10", "lastUpdated":"2013-09-10", "deleted":false, "id":5332552039815583000, "dateCreated":"2013-09-10", "file_filesize":7988 }, { "file_filename":"ClockToPrint.pdf", "file_date_created":"2013-09-10", "lastUpdated":"2013-09-10", "deleted":false, "id":5324327873266224000, "dateCreated":"2013-09-10", "file_filesize":7350 } ], "startRow":0, "endRow":4, "totalRows":4 }
Any more logs needed?
Thanks,
fatzopilot
Leave a comment:
-
Could you be more specific :)
You should see *at least* conversion from int to String on data leaving the server, if you are using a recent version. Please the inbound and outbound requests and logs showing what's happening if you're not seeing this.
Leave a comment:
-
Did you already try just declaring the field as type "text" in your .ds.xml?
Leave a comment:
-
Best way to deal with long ids
Hi,
I just noticed that my 64-bit hashcode generated ids get truncated (actually rounded) and that this seems to be a JS limitation.
So they're better dealt with as Strings in SGWT/JS.
I wonder what you consider best practice in this case if the DB uses full range (bigint(20)) numbers as ids.
Is there something like built-in autoconversion from String to int and vice versa or do I need to solve the conversion on a lower level?
Just changing the type of the id field to text did not seem to make a difference and converting the id to a string in a DMI does not seem to help either.
(The ids seem to be truncated on the server as the console already shows them truncated whereas in a bean, they are OK.)
Thanks,
fatzopilot
SmartClient Version: v8.3p_2013-09-07/PowerEdition Deployment (built 2013-09-07)Tags: None
Leave a comment: