Hi,
the XAF manual contains a section "Inherit From a Controller". I did this for the LinkUnlinkController in the common Module. I have overridden the CreateLinkView and UpdateActionsState todo some modifications. Now, if i start the Web Application i see there are 2 LinkUnlick controllers active. My inherited Controller, and the new? WebLinkUnlinkController.
So my question: How should we handle such scenarios. If i derive from an buildin common controller, probably in the next version you add an platform specific controller and then i have 2 of the same controllers active… So whats the recommended way?
thx
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hello Noxe,
Thanks for contacting us. Always inherit from a platform-specific controller. If there isn't any, inherit from the base controller.
It's also possible to consult us to know whether we plan to add new controllers in the near future. And finally, the best option is to contact us and describe your scenario, because perhaps it's possible to either achieve what you want without subclassing or by changing the code of the standard controller, for example via adding a new event or a method. This is because in general it is difficult to maintain such controllers for you.
Further details can be found here:
Reuse Controllers and Actions
Override Controller Behavior
Let me know in case of any further difficulty.
Thanks,
Dennis
Hi Dennis,
"Always inherit from a platform-specific controller. If there isn't any, inherit from the base controller." -> this was exaclty the case here. I inherited from the Base Controller since there was no platform specific controller. Now there is a Web specific controller, and now there are 2 controllers active. Also if there are platform specific controllers, i cannot place code in an common place.
So if you look at my Project you find an LinkUnlinkController - i have overridden the CreateLinkView to remove already linked objects and also the UpdateActionsState to remove the Delete Action.
Any Suggestions?
Hello Noxe,
>>public class LinkUnlinkController : DevExpress.ExpressApp.SystemModule.LinkUnlinkController
As I've already said the only solution here is to inherit from the WebLinkUnlinkController.
>>Also if there are platform specific controllers, i cannot place code in an common place.
Sure and I am afraid this is how XAF is currently designed.
I have created two suggestion to improve the code of the LinkUnlinkController in future versions:
SystemModules.Link - Provide events to create and customize a custom Link ListView
SystemModules.Link - Exclude objects that are already linked to an object from the Link ListView
Regarding the DeleteAction, you can see that the UpdateActionsState method is called in the OnActivated, DataSource_CollectionLoaded, View_AllowNewAndAllowDeleteChanged, View_CurrentObjectChanged methods and so you can handle corresponding events to provide the same behavior without sub classing. Let me know if this helps.
>>Frame.GetController<DeleteObjectsViewController>().Active.SetItemValue(DeleteActionIsInactiveBesideAnLinkUnlinkController, !this.LinkAction.Active);
BTW, it is not correct to deactivate the whole controller. It can do useful work in the background and you may break this functionality. Instead, it's better to deactivate its DeleteAction. Please correct your code.
Last question: how often in your solution do you need to remove the DeleteAction when there are the Link/Unlink actions?
See also:
"AllowDelete = false" Disables Unlink Action
Thanks,
Dennis
Hi Dennis,
thx for the suggestions and the hint about the delete controller.
"Last question: how often in your solution do you need to remove the DeleteAction when there are the Link/Unlink actions?" -> always!
Noxe,
>>"Last question: how often in your solution do you need to remove the DeleteAction when there are the Link/Unlink actions?" -> always!
Thanks for the feedback! I will research this problem further, and most likely will create a new suggestion in this regard. For now, I remember customers complaining about the Delete action in the Role_Users_ListView. I admit that there may be other scenarios.
Even though it's easy to write a couple lines of code to remove the Delete Action, we could consider the possibility to change the default behavior.
I will get back to you with my results as soon as I can.
Thanks,
Dennis
Thx for the feedback Dennis! Yes there was once ago a discussion in the Forums about the Delete Action in the Role_Users_ListView. I have deactivated the Delete Action everywhere because i know the users, they dont look if the click on the Unlink or the Delete Action, and so the record is deleted…
>>Thx for the feedback Dennis! Yes there was once ago a discussion in the Forums about the Delete Action in the Role_Users_ListView. I have deactivated the Delete Action everywhere because i know the users, they dont look if the click on the Unlink or the Delete Action, and so the record is deleted…
Ok, I will take this into account. Thanks for the feedback!
Happy New Year, Noxe!
Thanks,
Dennis
>Happy New Year, Noxe!> Same to you Dennis!
Thanks a lot!
Hello Noxe,
>>
I will research this problem further, and most likely will create a new suggestion in this regard. For now, I remember customers complaining about the Delete action in the Role_Users_ListView. I admit that there may be other scenarios.
Even though it's easy to write a couple lines of code to remove the Delete Action, we could consider the possibility of changing the default behavior.
I will get back to you with my results as soon as I can.
<<
As I promised, I have finished my research and found that we need to seriously consider changing the default behavior with the Delete and New Actions (as well as with the corresponding AllowNew, AllowDelete flags) and provide more flexibility to control the Link/Unlink actions.
I have created a new product feature (Nested ListView Usability Improvements) that for now, consists of the following references to the suggestions, questions and forum threads:
SystemModules.Link - the AllowNew and AllowDelete attributes for nested ListView should not impact the Link and Unlink actions
SystemModules.Delete - Usability of ListView that represents Many-To-Many collection
SystemModules.Link - Exclude objects that are already linked to an object from the Link ListView
SystemModules.Link - Provide events to create and customize a custom Link ListView
SystemModules.Delete - Provide the capability to deny the Delete operation for some collection property
Persistent.BaseImpl - Remove the Delete action from the nested Role ListView of the root User DetailView
Inherit from an built-in Controller
The LinkDetailViewController should not add objects in case of many-to-many association.
How to remove Delete button when LinkUnlink are active
hiding an action an listview
Briefly, what people mostly want is the following:
Feel free to add your vote to these suggestions to show us that this is important to you. Thanks for the help.
Thanks,
Dennis
Hi Dennis,
we drifted away from my original issue. How should i implement now my functionality for Win/Web? Since there is now an LinkUnlinkController and an WebLinkUnlinkController, how can i implement my platform independend code?
Hello Noxe,
>>
we drifted away from my original issue. How should i implement now my functionality for Win/Web? Since there is now an LinkUnlinkController and an WebLinkUnlinkController, how can i implement my platform independend code?
<<
Sorry for the inconvenience, I thought that I have already answered your question above:
>>>>public class LinkUnlinkController : DevExpress.ExpressApp.SystemModule.LinkUnlinkController
>>As I've already said the only solution here is to inherit from the WebLinkUnlinkController.
>>>>Also if there are platform specific controllers, i cannot place code in an common place.
>>Sure and I am afraid this is how XAF is currently designed.
>>I have created two suggestion to improve the code of the LinkUnlinkController in future versions:
>>SystemModules.Link - Provide events to create and customize a custom Link ListView
>>SystemModules.Link - Exclude objects that are already linked to an object from the Link ListView
To reiterate, it's now impossible to implement a platform-independent code to accomplish your task without changing the sources and rebuilding our libraries or without creating descendants of the controllers for each platform and duplicating the code. I have created corresponding suggestions to improve the LinkUnlinkController to make it possible to accomplish your task by handling an event. Is this clear now?
Should you have any additional questions, let me know. I will be glad to help you.
Thanks,
Dennis