Set Entity values inside Editor Form controller

Hi all
I have

    
public class PaA01aEdit extends AbstractEditor<PA> 

and inside

    
 public void init(Map<String, Object> params) 

i use:

    
PA item = (PA) WindowParams.ITEM.getEntity(params);
item.setXA01A(true);

to set a value

the field is not present on the layout for the EditForm and the dataSource uses a view that contains all the fields

I close the form with a custom action which does:

    
                dsContext.commit();
                runReport();
               close("arhidoc$PA.a01.edit");

the window close fine and I see that the XA01A is modified in the screen from which this window was open. But when I close that screen I get “
Do you want to discard unsaved changes?” and the value does not update in the database
How do I have to do it?

Thank you

The normal place of setting attributes of an edited instance is postInit() method - see AbstractEditor. You can use getItem() to get the instance. However, I’m not sure that it is the cause of your problem. This message is shown when you close a screen and there are datasources in “modified” state, which is strange because you invoke dsContext.commit() before. You can set a breakpoint to com.haulmont.cuba.gui.data.impl.DsContextImpl#isModified and watch what datasource is modified and what entities it contains in itemsToCreate, etc.

postInit did the job, thank you