4.2.1.3. Using initNewItem Method
Initial values can also be defined in the initNewItem() method of the screen controller of the created entity.
Consider the following entities:
In the demo application, CustomerDetails attribute (info) is edited on the same screen as Customer itself. It requires creating of a CustomerDetails instance together with the owning Customer.
-
customer-edit.xml - a customer edit screen descriptor. It contains a nested datasource for a linked
CustomerDetailsinstance. TheinfoFieldtext area component is connected to this datasource. -
CustomerEdit.java - the screen controller. It defines the
initNewItem()method that creates a newCustomerDetailsinstance and sets it to a newCustomer. The created instance will be available through the nested datasource and later saved to the database when the screen is committed.