I am trying to declaratively load a Lookupfield but the example code in documentation displays an empty Lookupfield. The entity table has data and then entity browser also shows data.
I did add @LoadDataBeforeShow after I submitted this post but still no help.
Is the fact my controller is a screen vs StandardLookup<> make a difference? The Cuba generated “browse” works fine. My goal is a screen with several dropdown controls populated from separate entities.
Got you finally. @LoadDataBeforeShow works fine. But you have installed wrong attributes for the lookup component. You should have set optionsContainer. See the example below:
I tried your code and the sample link. I tried this at least 20 different ways. I tried through the screen designers using the intelligent pickers and I get NO design time or compiling errors. I either get no data or runtime errors. I know I’m a newbie but . . . .
One additional note, I created my datamodel from the “generate model” in datastore (SQL Server). So my my entity class looks a little different then examples. But i even set it to a StandardEntity from the BaseIntegerIdEntity the generator chose. So I can’t see an issue there.
Final resolution to populate the dropdown values in a LookupField was I was binding to dataContainer=“xxx” and property=“xxx”
but what I needed to do is bind to is optionContainer and captionProperty. These are what the populate the dropdown.
I also bound dataContainer/property to instance of my class
Then on some screen event I got the selected value by (after injection of lookupfield);
TableGroup tableGroup = (TableGroup) LUFTableGroup.getValue();
Full example code (used [] brackets instead of angled);
[data]
[collection id=“tableGroupDc” class=“com.jsonedi.jediadmin.entity.TableGroup” view="_local"]
[loader id=“tableGroupDl”]
[query][![CDATA[select e from jediadmin_TableGroup e]]][/query]
[/loader]
[/collection]
[instance id=“tableGroupId” class=“com.jsonedi.jediadmin.entity.TableGroup”/]
[/data]
[layout]
[lookupField id=“LUFTableGroup” optionsContainer=“tableGroupDc” captionProperty=“tGName” dataContainer=“tableGroupId” property=“tGName”/]
[/layout]