Hi everyone,
I have a similar problem. I have a One-to-One relation between a main entity (say Person) connect with an optional second one (say ArtistInfo).
(schematic)
Person 1 → 1/0 ArtistInfo
I use a PickerField to visually connect Entities. (as in Docs).
When I click on the lens in PickerField (in parent editor) it opens an editor for ArtistInfo entity (child editor), That’s OK.
I want to display (not modify) information from Person entity modified in parent Editor.
I tried different solution:
In ArtistInfo screen CollecionDatasource with query select p from project$Person p where p.artist.id = ds$ArtistInfo
that should return 0 or 1 results, but I think I can’t connect a FieldGroup to CollectionDatasource
Passing additional parameters in PickerFieldOpenAction of the parent editor
----- Code Snippet Father Editor----
@Override
public void ready() {
Person p = getItem();
Map<String,Object> params = new HashMap<String,Object>();
params.put("person",p);
PkpArtist.getOpenAction().setEditScreenParams(params);
}
----- Code Snippet ----
and retrieving in Child Editor.
----- Code Snippet Child Editor ----
@Override
void init(Map<String, Object> params) {
p = (Person) params.get("person") --> Works great
// Datasource Creation
personDS = new DsBuilder(getDsContext()).setJavaClass(Person.class)
.setViewName(View.LOCAL)
.setId("personDs").buildDatasource()
personDS.setItem(p)
}
@Override
void ready() {
//personDS.setItem(p)
personDS.refresh()
}
----- Code Snippet ----
Here in ArtistInfo screen XML is defined a single instance datasource connected to Field Group that is not initialized at editor opening (single instance DS does not get data from DB) So I created programmatically and tried to setItem() in init() or ready()
with no success.
Hello i’ ll tried your example but wih no success.
Ok for optimal parameter passing between two editors using ParamsMap.of that works perfectly, but i still have null pointer Exception in personDS.setItem(parameter) because personDS is null.
It seems it is not created by XMA declaration. I tried again to move setItem() in ready method, but no success. Follows my groovy snippet of code for ArtistInfoEdit.groovy and PersonDS xml definition.
Thank yuo in advance for your time,
Fabrizio
------------------------------------- Groovy --------------------------------------------------- ArtistInfoEdit.groovy
private Person p