Home » Eclipse Projects » Eclipse Scout » [NEON] Smart fields with db-lookup service
[NEON] Smart fields with db-lookup service [message #1720338] |
Sun, 17 January 2016 18:33 |
Marco Dörfliger Messages: 46 Registered: January 2015 |
Member |
|
|
So I ported a small mars project over to neon M4, just for fun. Wasn't actually that traumatic I have to say.
The only glitch I've come against is with my smartfields getting sort of 'stuck'. The first (top-most) entry in the list is always selected, regardless which value in the list is chosen. The second time I select that value however, the correct value is chosen.
Take a look at this smartfield:
- Initially, regardless which item I select (let's say Zagreb), Copenhagen will be selected. (By setting breakpoints however, I can see that the correct value is indeed chosen in the back-end, it's just not displayed).
- If I select Zagreb a second time, it appears correctly on the UI.
My customer field
@Order(20.0)
public class CustomerField extends AbstractSmartField<Long> {
@Override
protected String getConfiguredLabel() {
return TEXTS.get("Customer");
}
@Override
protected Class<? extends ILookupCall<Long>> getConfiguredLookupCall() {
return CustomerLookupCall.class;
}
@Override
protected boolean getConfiguredMandatory() {
return true;
}
@Override
protected void execChangedValue() throws ProcessingException {
getLicenseTextField().setValue(null);
}
}
The lookup call (note: no annotations):
public class CustomerLookupCall extends LookupCall<Long> {
private static final long serialVersionUID = 1L;
@Override
protected Class<? extends ILookupService<Long>> getConfiguredService() {
return ICustomerLookupService.class;
}
}
The service interface:
@TunnelToServer
public interface ICustomerLookupService extends ILookupService<Long> {
}
And the implementing service class:
@Server
public class CustomerLookupService extends AbstractSqlLookupService<Long> implements ICustomerLookupService {
@Override
protected String getConfiguredSqlSelect() {
return "select id, name from customer";
}
}
I didn't find anything on bugzilla or in the forum, yet it seems the sort of thing that someone might have noticed by now. There is a working smartfield on the 'contacts' demo (the country selection), but the data is all populated in the client side so I think the problem might be having the lookup service implementation on the server-side.
Something else: I get these log entries for each row which is read by the lookup call:
2016-01-17 19:17:16,206 WARN qtp918312414-15 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
They are generated in the constructor of LookupRow (line 163), possibly erroneously.
Cheers all,
Marco
[Updated on: Sun, 17 January 2016 20:04] Report message to a moderator
|
|
| |
Re: [NEON] Smart fields with db-lookup service [message #1720643 is a reply to message #1720338] |
Wed, 20 January 2016 06:47 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
Marco Dorfliger wrote on Sun, 17 January 2016 19:33Something else: I get these log entries for each row which is read by the lookup call:
2016-01-17 19:17:16,206 WARN qtp918312414-15 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
2016-01-17 19:17:21,040 WARN qtp918312414-21 o.e.scout.rt.shared.services.lookup.LookupRow - Max column index (2) greater than provided data (1). [httpSessionId: '1b5mvdod84aew917l2c8bpmtl', majorPrincipal: 'mddorfli']
They are generated in the constructor of LookupRow (line 163), possibly erroneously.
Can you put a breakpoint at:
org.eclipse.scout.rt.server.jdbc.lookup.AbstractSqlLookupService.execLoadLookupRows(String, String, ILookupCall<T>)
And check how your data Object[][] looks like?
I can produce those lines with a data variable looking like this:
Object[][] data = new Object[][]{
new Object[]{1L, "Helsinky"},
new Object[]{2L},
new Object[]{3L},
new Object[]{4L, "Zagreb"}
};
|
|
|
Re: [NEON] Smart fields with db-lookup service [message #1720895 is a reply to message #1720643] |
Thu, 21 January 2016 17:34 |
Marco Dörfliger Messages: 46 Registered: January 2015 |
Member |
|
|
Thanks for that Jeremie. I had searched for a working SQL-based example in the contacts demo, but it was hidden in the 'work' tab. I'll search by class type next time.
Well I found the cause of both problems.
The smartfield was misbehaving because I had not included the <all>, <text> and <key> tags in the lookup SQL. Let that be a lesson to everyone. To correctly function, the select must be specified as follows:
@Override
protected String getConfiguredSqlSelect() {
return ""
+ "SELECT id, "
+ " name "
+ " FROM customer "
+ " WHERE 1 = 1 "
+ "<key>AND id = :key</key> "
+ "<text>AND UPPER(name) LIKE UPPER(:text || '%')</text> "
+ "<all></all>";
}
Regarding the logs, I suspect this is a version difference between eclipse scout M3 and eclipse scout M4. You see, I created the project using the eclipse scout M3 release, and when M4 came out, rather than recreate it, I just reopened the workspace. I believe that the M3 code is still residual.
Well I tracked the problem down to this code in AbstractLookupService.java:
public static <KEY_TYPE> List<ILookupRow<KEY_TYPE>> createLookupRowArray(Object[][] data, ILookupCall<KEY_TYPE> call, Class<?> keyClass) {
return createLookupRowArray(data, data != null && data.length > 0 ? data[0].length : 0, call, keyClass);
}
When I open the same class in the Contacts demo app, this is the source code:
public static <KEY_TYPE> List<ILookupRow<KEY_TYPE>> createLookupRowArray(Object[][] data, ILookupCall<KEY_TYPE> call, Class<?> keyClass) {
int maxColumnIndex = data != null && data.length > 0 ? data[0].length - 1 : 0;
return createLookupRowArray(data, maxColumnIndex, call, keyClass);
}
My guess is that the issue has been fixed in the M4 release, and I just haven't figured out how to refresh the code repository properly.
Btw, has anyone noticed that maven downloads a lot of stuff on the first compile? It could have been my connection, on the initial build of the contacts demo it download poms and jars for a good 20 mins.
|
|
| |
Goto Forum:
Current Time: Mon Sep 23 11:12:31 GMT 2024
Powered by FUDForum. Page generated in 0.03440 seconds
|