Lets say we have an Edit Gui that call a Service (Bean) in the backend. The Service would calculate some fields and return the newly calcultated Buffer to the client. How would I reflect the changed/calculated fields on the Gui (without setting each field explicity)?
private void calculate() {
Salary sal = salaryDs.getItem();
if (sal.getEmpId() == null) return;
//call Service
Salary newSal = calculationService.calculateAmounts(sal);
//copy fields from result to GUI
//newSal.pcCopyFields(sal, null); //copy fields
//salaryDs.setItem(newSal);
//setItem(newSal);
}
Well, it seems that you do quite standard things: reload the same entity with different values in attributes and set it to the same datasource. The visual components bound to the attributes should immediately show the new values.
Let’s go to details: what components and attributes don’t work as expected?
When using salaryDs.setItem on first look the Gui seems to be fine. I can see the changed (calculated) fields. After Clicking ok, I can also see the values in the browse Gui. However after reopening from the overview all values are disappeard again.
So the new values are displayed in UI, but not saved to the database.
Most probably your datasource does not become “dirty” to be automatically saved on screen commit. This is because when you set an entity to a datasource, the framework decides that this entity is just loaded and the datasource is clean until a user makes changes in UI fields.