Implement Service with Datamanipulation


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

What is the type of the datasource? Could you provide its definition in the screen XML?
And why do you use “newSal.pcCopyFields()”?

Hi Konstatin,

newSal.pcCopyFields() was just a try since I have not found any documentation, so I was guessing.

public class SalaryEdit extends AbstractEditor {
private Datasource salaryDs;

XML Definition of the gui is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

The idea is, that the service would do some calculations on the passed databuffer und returns the result to the gui, from where it would be saved.


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?

And try first to set null, then the new item:


Hi Konstatin,

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.

Hi Josef,

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.

Try to set the datasource “dirty” explicity:

((DatasourceImplementation) salaryDs).modified(newSal);

Hi Konstantin,
that did the trick…