Multi Column SmartField [message #1553263] |
Thu, 08 January 2015 15:55 |
|
Hello there
according to this blog entry and this wiki entry it's possible to provide a multi column smart field.
Now I was thinking of updating other form fields after a value from the smart field was selected.
Lets assume that the smart field has the following columns:
ID|Firstname|Lastname|Street|ZipCode|City
After selecting an entry I'd like to update the corresponding fields on the form. Namely the Firstname|Lastname|Street|ZipCode|City fields.
Is this possible?
Thanks
Peter
|
|
|
|
|
Re: Multi Column SmartField [message #1554593 is a reply to message #1554450] |
Fri, 09 January 2015 09:32 |
|
Ok. It seems to work.
execChangeValue does the trick for retrieving the selected values.
In order to fill the multi column smart field with an SQLLookupService I overwrote the method in order to be able to access the other columsn fromt the SQL statement:
/* (non-Javadoc)
* @see org.eclipse.scout.rt.server.services.lookup.AbstractSqlLookupService#execLoadLookupRows(java.lang.String, java.lang.String, org.eclipse.scout.rt.shared.services.lookup.ILookupCall)
*/
@Override
protected List<ILookupRow<Long>> execLoadLookupRows(String originalSql, String preprocessedSql, ILookupCall<Long> call) throws ProcessingException {
Object[][] data = SQL.selectLimited(preprocessedSql, 1000, call);
if (getConfiguredSortColumn() >= 0) {
sortData(data, getConfiguredSortColumn());
}
try {
Class<?> genericsParameterClass = Object.class;
try {
genericsParameterClass = TypeCastUtility.getGenericsParameterClass(getClass(), ILookupService.class);
}
catch (IllegalArgumentException e) {
System.err.println("Unable to calculate type parameters for lookup service '" + getClass().getName() + "'. No key type validation will be performed.");
}
List<ILookupRow<Long>> rows = createLookupRowArray(data, call, genericsParameterClass);
int i = 0;
for (ILookupRow<Long> row : rows) {
CustomerCompleteTableRowData bean = new CustomerCompleteTableRowData();
bean.setFirstname((String) data[i][1]);
bean.setLastname((String) data[i][2]);
bean.setCity((String) data[i][5]);
bean.setStreet((String) data[i][3]);
bean.setZip((String) data[i][4]);
row.setAdditionalTableRowData(bean);
i++;
}
return rows;
}
catch (IllegalArgumentException e) {
throw new ProcessingException("Unable to load lookup rows for lookup service '" + getClass().getName() + "'.", e);
}
}
I don't know if this is the most appropriate way to achieve a multi column smart field with DB backend or not. If not, please let me know. I'm eager to learn
Peter
|
|
|
Powered by
FUDForum. Page generated in 0.04557 seconds