Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Casting query results
Casting query results [message #1053221] Fri, 03 May 2013 08:21 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 310
Registered: August 2011
Senior Member

I have a form witfh some fields and a table on it. Normally to load the data in the processing Service I use the selectInto method to load the fields and the table data.

so to load the formData I have two select into calls

SERVICE.selectInto("the sql", formData);
SERVICE.selectInto("the sql", formData.getTable());

Now I have a more complex case where I have to process the table data myself before I can add it to the formData so I use a 'normal' select to get the table data.

Object[][] tempResults ="the sql");

Then I process the data which means changing some values, removing records from it etc.

In the end I add the processed records 1 by 1 to the formData with:


The problem with this is that the automatic casting (database types to column types) that Scout does for me is not executed. I solved this by doing it myself for every field like:

tempResults[iRow, iColumn] = TypeCastUtility.castValue(tempResults[iRow, iColumn] , Boolean.class);

The question is, is there a better way to do this? In the way I did it, it works but it is error-prone. If I add a column, change its type etc, change the order of columns etc. I always have to remember to adapt casting.

Regards Bertin

Re: Casting query results [message #1053244 is a reply to message #1053221] Fri, 03 May 2013 11:15 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 817
Registered: October 2011
Senior Member
The SDK should generate setter methods on the AbstractTableFieldData contained in your FormData.

This way, in your for each loop, you can do:
//table is somthing like "formData.getTable()" you can declare it outside of your loop.
int i = table.addRow(ITableHolder.STATUS_NON_CHANGED);
table.setSummary(i, "summary");
table.setStatus(i, "my Status");

If you send the FormData back and forth between client and server, you will probably also need:
* table.clearRows() before your loop (corresponding to AbstractTableFieldData#clearRows())
* table.setValueSet(true) after your loop (corresponding to AbstractTableFieldData#setValueSet(boolean)). This will indicate that you have set values in the TableFieldData. I think it is an obligation to tell "a table with no rows". Otherwise the form will ignore your TableFieldData when you do importFormData(..) in the client.

Let me know if it works for you.

[Updated on: Fri, 03 May 2013 11:16]

Report message to a moderator

Previous Topic:Large RemoteFile
Next Topic:howto add a new button to toolbar
Goto Forum:

Current Time: Sat Dec 20 05:57:22 GMT 2014

Powered by FUDForum. Page generated in 0.01635 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software