Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Marco Dörfliger is currently offline Marco DörfligerFriend
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:
index.php/fa/24673/0/

  1. 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).
  2. 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 #1720638 is a reply to message #1720338] Wed, 20 January 2016 06:38 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
I have double check your example and I cannot say what is wrong.

We have exactly the same example in our Contacts Demo Application:
* PersonForm > OrganizationField
* OrganizationLookupCall
* IOrganizationLookupService
* OrganizationLookupService
* SQLs#ORGANIZATION_LOOKUP
... and it works as expected.

Are you sure that your id field in the customer table is unique?
Re: [NEON] Smart fields with db-lookup service [message #1720643 is a reply to message #1720338] Wed, 20 January 2016 06:47 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Marco Dorfliger wrote on Sun, 17 January 2016 19:33
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.


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 Go to previous messageGo to next message
Marco Dörfliger is currently offline Marco DörfligerFriend
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. Smile I'll search by class type next time. Smile

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.
Re: [NEON] Smart fields with db-lookup service [message #1720930 is a reply to message #1720895] Thu, 21 January 2016 21:22 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Marco Dorfliger wrote on Thu, 21 January 2016 18:34
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.


Matthias Villiger has explained the procedure here:
https://www.eclipse.org/forums/index.php?t=msg&th=1072536&goto=1718229&#msg_1718229

You just need to changed some versions in your parent pom.
* scout.version property == 5.2.0.M4
* parent: use the version 2.0.3 of the maven_rt_plugin_config-master module.

As a reference, have a look a the contacts App parent pom:
org.eclipse.scout.contacts/pom.xml (M4 Branch)

Marco Dorfliger wrote on Thu, 21 January 2016 18:34
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.


Yes I think that it is how the maven world works...
Previous Topic:[Neon]ValidationRule
Next Topic:Getting List of Table pages handle
Goto Forum:
  


Current Time: Mon Sep 23 11:12:31 GMT 2024

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

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

Back to the top