Refresh Datagrid from Non-Persisted Entity

I am binding a datagrid to a non persisted entity that is programmatically populated based on user input. I get an error a refresh load() of DataLoader (see below)

private DataGrid<JobSchedule_Stage> jobScheduleGrid;

private CollectionLoader<JobSchedule_Stage> jobScheduleStageDl;

private ArrayList<JobSchedule_Stage> jobScheduleStageLst; //the non-persisted entity bound 

@Install(to = "jobScheduleStageDl", target = Target.DATA_LOADER)
private List<JobSchedule_Stage> jobScheduleStageDlLoadDelegate(LoadContext<JobSchedule_Stage> loadContext) {
    return jobScheduleStageLst;
public void onBeforeShow(BeforeShowEvent event) {
    jobScheduleStageLst = new ArrayList<>(); //start datagrid as empty

Public void RefreshDatagrid() {   
    . . . .load data into jobScheduleStageLst . . . .
      jobScheduleStageDl.load(); //This errors with:

//DataContext already contains an instance with null id: com.jsonedi.jediadmin.entity.nonpersisted.JobSchedule_Stage-null [new]

I fixed this myself but wanted to post a reply for others. In this use case using a DataLoader is pointless. Use the CollectionContainer without a DataLoader. Just @Inject a screen’s CollectionContainer and bind the List with the setItems(List) method as needed.

1 Like