Hi,
Are there any pros / cons of accessing data (read or write) via the datasource.getItem() vs data-aware UI-widgets (which reference the datasource anyway) throughout the life of a controller (initialisation, validation, etc)?
Thanks,
Eddy
Hi,
Are there any pros / cons of accessing data (read or write) via the datasource.getItem() vs data-aware UI-widgets (which reference the datasource anyway) throughout the life of a controller (initialisation, validation, etc)?
Thanks,
Eddy
Hi Eddy,
In my opinion, it is more logical to work with data via entity attributes, i.e. via datasource.getItem().setXyz(). This is the same as setting value to a visual component bound to the attribute, but there is a subtle difference:
If your visual component bound not to an immediate attribute, say “name”, but to an attribute of a referenced entity, say “customer.name”, then setting a value to the component will update the value in the entity instance, but the opposite is not true: setting a value to the “customer.name” attribute will not be reflected in the visual component. This is because datasources listen to changes in immediate attributes only.
In most cases this difference can be ignored because visual components are usually bound to immediate attributes of instances located in datasources.