Cannot read property of null Error [message #1828024] |
Fri, 29 May 2020 06:03  |
Eclipse User |
|
|
|
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 09:25   |
Eclipse User |
|
|
|
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.
|
|
|
|
Re: Cannot read property of null Error [message #1828182 is a reply to message #1828156] |
Wed, 03 June 2020 07:06   |
Eclipse User |
|
|
|
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.
[Updated on: Wed, 03 June 2020 07:07] by Moderator
|
|
|
|
Re: Cannot read property of null Error [message #1828255 is a reply to message #1828238] |
Fri, 05 June 2020 02:03  |
Eclipse User |
|
|
|
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.
[Updated on: Fri, 05 June 2020 02:04] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04190 seconds