Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Enable / disable controls / forms
Enable / disable controls / forms [message #1064654] Thu, 20 June 2013 12:29 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
Hi,

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.

Regards Bertin
Re: Enable / disable controls / forms [message #1064665 is a reply to message #1064654] Thu, 20 June 2013 13:14 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
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.

I hope it helps.
icon7.gif  Re: Enable / disable controls / forms [message #1064672 is a reply to message #1064665] Thu, 20 June 2013 13:41 Go to previous message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
Registered: August 2011
Senior Member
Thanks,

setEnabledGranted(boolean) will work. Just tested it and it disables all the controls with one call.

regards Bertin.

Previous Topic:SWT application fails to start
Next Topic:target for kepler
Goto Forum:
  


Current Time: Fri Apr 19 23:46:48 GMT 2024

Powered by FUDForum. Page generated in 0.02919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top