Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Cannot read property of null Error
Cannot read property of null Error [message #1828024] Fri, 29 May 2020 10:03 Go to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello,
I want to implement a Lookup call that display a table like custom table in the widget demo, I created an AbstractLookupCall where I defined the table data structure and added the method

getConfiguredColumnDescriptors in the Smart field


I am getting the error
Cannot read property of null Error
when clicking on the smart field. can any one give me a hint how to solve this issue ?
Kind Regards
Re: Cannot read property of null Error [message #1828029 is a reply to message #1828024] Fri, 29 May 2020 13:25 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Perhaps your mapping between the LookupRow#additionalTableRowData and the ColumnDescriptor is wrong? You need to define a bean where the name of the getter/setters matches the propertyName of the descriptor. Like in the widgets app LookupCall:

// #execCreateLookupRows
LocaleTableRowData bean = new LocaleTableRowData();
        bean.setCountry(locale.getCountry());
        bean.setLanguage(locale.getLanguage());
        row.withAdditionalTableRowData(bean);


And in the definition of the SmartField:

         @Override
          protected ColumnDescriptor[] getConfiguredColumnDescriptors() {
            return new ColumnDescriptor[]{
                new ColumnDescriptor(null, "Text", 200),
                new ColumnDescriptor(LocaleTableRowData.country, TEXTS.get("Country"), 90),
                new ColumnDescriptor(LocaleTableRowData.language, TEXTS.get("Language"), 90)
            };
          }


If that's not your problem, please post a stack-trace.


Eclipse Scout Homepage | Documentation | GitHub
Re: Cannot read property of null Error [message #1828156 is a reply to message #1828029] Tue, 02 June 2020 19:20 Go to previous messageGo to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hello,
After several trial I came out to the following, I can not use LocalLookup to realise what I am looking for, in fact I have duplicate bills in my database but for different companies, I thought that implementing a table on the SQL Lookup is going to help me resolve the duplicates
but the fact that this is not useful only with locallookup make it impossible to implement it.
Kind Regards
Re: Cannot read property of null Error [message #1828182 is a reply to message #1828156] Wed, 03 June 2020 11:06 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
Hmmm, not sure if I understand everything correctly. A LocalLookupCall is (as the name suggests) used when data requested by the lookup is already available on the client itself, which is e.g. the case for CodeTypes, values of an Enum, etc. When you need to lookup data from a database you cannot use the LocalLookupCall. Instead you must access the Scout backend through a LookupService, which reads and returns the data from the database.

The LookupCall/-Service does not care about SQL statements, duplicates and stuff. Its only purpose is to create and return LookupRow objects. A LookupRow basically has a key property, which identifies the LookupRow (and often references a record in a database too) and a text property which is displayed to the user. How these LookupRows are created is up to the programmer, there's no magic involved ;-)

Here's a description on how to implement a LookupCall/-Service. Note that you don't have to extend AbstractSqlLookupService. You could also extend AbstractLookupService and combine SQL- and business logic there to deal with duplicates.


Eclipse Scout Homepage | Documentation | GitHub

[Updated on: Wed, 03 June 2020 11:07]

Report message to a moderator

Re: Cannot read property of null Error [message #1828238 is a reply to message #1828182] Thu, 04 June 2020 15:16 Go to previous messageGo to next message
Oueslati Anis is currently offline Oueslati AnisFriend
Messages: 128
Registered: June 2014
Location: Paris
Senior Member
Hi,

I noticed that if entries have the same text they are merged for the user in the smart field, so in this case the system does not know witch key to use to fetch data from database, in this case I wanted to create a table row ( like for the locallookup ) and display more additional informations that could help geeting only one key. the way I see it is that we can not create personal lookuprow in case of SQL lookup row, is that right ?
Kind Regards
Re: Cannot read property of null Error [message #1828255 is a reply to message #1828238] Fri, 05 June 2020 06:03 Go to previous message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 204
Registered: September 2012
Location: Baden-Dättwil, Switzerla...
Senior Member
No, that's not right. The simplest SQL statement I can do with Apache Derby using the AbstractSqlLookupService is this:

  protected String getConfiguredSqlSelect() {
    return     "VALUES ('123', 'foo'), ('234', 'foo'), ('345', 'bar'), ('456', 'baz') "
      + " <key></key> " // <1>
      + " <text></text> " // <2>
      + " <all></all>"; // <3>
  }


As you see there are two records with the text "foo". As expected the SmartField renders 4 rows in the proposal popup with two rows having the text "foo". When the user selects the first foo-row the value of the SmartField is "123", for the second foo-row the value is "234". Of course the user cannot distinct the two records in the UI because he/she never sees the technical key, but only the text. However, the system always knows which key has been selected and nothing gets merged.

If the key is not unique you cannot determine which row has been selected by the user. That's the contract/API of the SmartField and the LookupCalls: you need a *unique* key. Since the key can be any (serializable) object, you may need to use a composite object as key to deal with your duplicates. And as I said earlier: if you cannot manage to fit the whole duplicate/unique key logic into a single SQL statement, don't extend AbstractSqlLookupService but simply AbstractLookupService and implement whatever it takes to create the proper lookup rows your user should see.


Eclipse Scout Homepage | Documentation | GitHub

[Updated on: Fri, 05 June 2020 06:04]

Report message to a moderator

Previous Topic:Cache example
Next Topic:Scout Create Wizard not working properly
Goto Forum:
  


Current Time: Fri Apr 26 03:42:14 GMT 2024

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

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

Back to the top