TablePageData and SearchForm [message #1413318] |
Thu, 28 August 2014 09:10 |
Nils Israel Messages: 72 Registered: May 2010 |
Member |
|
|
Hi,
I am testing the cool new feature TablePageData. Without a searchform it is working fine. But let's say there is a TablePage with 3 Columns: IDColumn, NameColumn and TownColumn.
The corresponding SearchForm has two fields: NameField and TownField.
Without TablePageData the relevant lines in the OutlineService are:
public Object[][] getUserData(UserSearchForm formData){
StringBuilder statement = new StringBuilder();
statement.append(""
+"SELECT "
+" id, "
+" name, "
+" town "
+"FROM "
+" users "
+"WHERE 1=1 ");
if (!StringUtility.isNullOrEmpty(formData.getName().getValue())){
statement.append(" AND name like :name ");
}
if (!StringUtility.isNullOrEmpty(formData.getTown().getValue())){
statement.append(" AND town like :town ");
}
return SQL.select(statement.toString(), formData);
}
With the TablePageData the lines are:
public UserTablePageData getUserData(UserSearchForm formData){
UserTablePageData = new UserTablePageData();
StringBuilder statement = new StringBuilder();
statement.append(""
+"SELECT "
+" id, "
+" name, "
+" town "
+"FROM "
+" users "
+"WHERE 1=1 ");
if (!StringUtility.isNullOrEmpty(formData.getName().getValue())){
statement.append(" AND name like :name ");
}
if (!StringUtility.isNullOrEmpty(formData.getTown().getValue())){
statement.append(" AND town like :town ");
}
statement.append(""
+"INTO "
+" :{id} "
+" :{name}, "
+" :{town}");
SQL.selectInto(statement.toString(), formData, tablePageData);
return tablePageData;
}
But now I get a ProcessingException: expected a single value for ":{name}" but got multiple values.
Obviously the problem occurs because the field in the SearchForm an the column in the TablePageData have the same name.
It gets strange when I change the order of the bind bases:
SQL.selectInto(statement.toString(), tablePageData, formData);
I get all table rows and no error message if I leave the search fields empty. And so I thought this may be a workaround. But if I fill the name or the town field with a search string that should lead to some rows I get an empty (no rows) TablePageData. The strange thing is, that the debug log doesn't even show a sql query. So there is an empty TablePageData and no error message indicating that something has gone wrong.
Is there something I can do without changing the column or the search field names?
Kind regards,
Nils
|
|
|
Re: TablePageData and SearchForm [message #1413390 is a reply to message #1413318] |
Thu, 28 August 2014 12:24 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
This is a really interesting point. Thanks for your detailed description.
Quick/untested idea:
I think you can provide a name to the tableData with NVPair (class org.eclipse.scout.commons.holders.NVPair):
SQL.selectInto(statement.toString(), formData, new NVPair("table", tablePageData));
And then in your bindings:
INTO
:{table.id}
:{table.name},
:{table.town}
If this does'nt work, fell free to tell me. We need to find a solution for your problem.
___
Edit 08.09.2014:
By the way, I have written "untested", but I wrote the exact same code for the MiniCRM example on GitHub in october 2013. See StandardOutlineService.
[Updated on: Mon, 08 September 2014 18:42] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02818 seconds