in my app I have many forms to edit data and many processServices to execute the actions, the data is stored across many tables. The users are allowed to edit this data. At some moment in time some action is made upon this data that it is, because of some business rules, no longer allowed to change the data anymore.
This is easy to do in my process service by just checking the data and give some VetoException, but this is OK for business rules but not for the user because he can change the data on the form and gets an error afterwards.
What I want is to disable the controls on the forms as soon as it is not allowed to change the data anymore. Is there a way to do this easy in Scout.
With easy I mean, for example, as soon as a user does not have the permission (authorization) to change the data, all controls are automatically disabled so the user directly sees that he cannot change the data.
Scout provides on each fields the possibility to call setEnabled(boolean).
On composite fields (like group box) the enablement value is propagated to the child fields.
So you can call setEnabled(false) on the MainBox of your form, and call setEnable(true) on the CancelButton and you should be fine. It is possible to do so in the execLoad() of the form handler.
=> This is fine for Business logic.
Another possibility provided by Scout deals with permission (authorization). In my opinion, it is a bad Idea to misuse this layer for business logic.
On the fields you get a setEnabledPermission(Permission): you can use this with a Permission object. If the user has not the corresponding Permission, the field will be disabled.
If you do not use the Permission mechanism from scout, there is also a setEnabledGranted(boolean) method. It is exactly the same (basically setEnabledPermission resolves the permission with the IAccessControlService# .checkPermission(Permission) and calls setEnabledGranted with the result.).
You will also find these two methods on the form as convenience (they just propagate the call to the mainbox).
At the end: a field is enabled only if the business logic layer tells so and the permission layer tells so.