Search This Blog

Friday, September 30, 2016

How to find and deactivate a problematic Controller "on the fly" via an application UI for troubleshooting purposes

I wanted to repost a troubleshooting tip our old XAFer and MVP Dave Hesketh has kindly provided in the Support Center today. BTW, Dave also provides XAF training and custom development services, based out of Ontario, Canada, so this may be not the last thing you would want to learn from him and his website

So, let me focus on the problem and solution he described at https://www.devexpress.com/kb=T433881 and also also quickly show it all in action with one of the XAF demos:

"I have come across a few scenarios where something seems to be slowing down an XAF solution and it is tough to determine where the issue exists. This can then lead to hours of tearing out controllers to try and determine if one is problematic.

To make this process easier, I have created a module that you can add to an XAF solution to Enable and Disable controllers on the fly.

Once you add this module to your solution, you will find the "Show Controller Settings" action in the Tools menu. In the dialog that appears, you can enable or disable any controllers you wish, or click the "Disable Custom Controllers" to disable non-DevExpress controllers (A good starting place). 

Please note: Once you enable or disable controllers, you must re-open a view for the change to take effect. 
This solution has been tested on existing Win Applications only."





I remember a couple of similar requests from other guys, and indeed, this dynamic exclusion of Controllers without recompiling and restarting the whole app can be helpful when researching certain complex problems like performance or behavioral/visual side effects. For many other cases, the built-in Diagnostic Actionapplication log files, and performance profilers would suffice pretty well. 

Anyway, let's check how to use Dave's module with our MainDemo.Win app. Consider the following steps:

Monday, September 26, 2016

How to skip the logon dialog when debugging or testing an XAF app with the security system enabled

Sometimes during active development, you may find yourself in front of the logon form entering user credentials again and again, and it may eventually become boring. This simple to implement tip will not only save you development time, but also irritation. I wanted to highlight this technique for everyone here after assisting my colleague in this SC ticket + because another customer also found this solution helpful. Since, I also remembered that we have been using a similar thing internally for the installation tests of our demos, I think it is definitely time to let the rest of the world know about this as well.



Steps to implement


1. The instructions below imply that you have already created an XAF WinForms or Web app with the Security module, and its SecurityStrategyComplex and AuthenticationStandard components either using the Solution Wizard or manually. You likely also created predefined users and roles in code or using the application UI at runtime. Consult with the XAF online documentation for more details.

Thursday, September 15, 2016

Simplifying customization of Action controls - YOUR FEEDBACK IS NEEDED!

As you know, XAF provides abstractions for common UI elements like list and detail forms, their editors, main and navigation menus, etc. that enable XAF developers to accomplish common tasks for several supported platforms with less effort. Today I want to take a moment of your time and focus on popular customization tasks related to Actions - typically abstract UI elements that allow you to perform specific operations in response to end-user manipulations.



For instance, the ActionBase class, which is the super class for all Action types provides many useful members like Caption, ToolTip, Shortcut, PaintStyle, Enabled, Active, etc. that help you care less of technical implementation details for each specific platform or situation, at least for the popular tasks these members were designed for. It is also super easy to manage these properties and events in code or via the visual designers like the Visual Studio component designer for Controller or our own Model Editor.




Current approaches for customizing Action controls

The above looks very well (and many XAFers expressed this is one of the things they love the product for) and we have always been trying to keep this promise when designing our framework:
common and simple tasks can be done easily, while any specific or complex tasks are technically possible

But what about the second part of this promise with regard to Actions in practice? To answer this, it is best to evaluate it yourself for various tasks. Our documentation and support knowledge base contains many code examples for customizing Action controls in various places of an XAF application, and I grouped them below for your review.

How to provide a specific View layout for users of certain security roles

I would like to quickly promote a recent update to our old Code Example in the support database: https://www.devexpress.com/example=E274
I hope you find this solution helpful. Let me know in case of any questions, suggestions or share your experience with other XAFers on how you are doing a similar task at the moment. Thanks!

Scenario:
This example demonstrates how to show a custom View against a role of the currently logged user. Custom Views were created and customized through the Model Editor for each role separately. For more convenience, custom Views have a name of a role in the Id attribute. For instance: Contact_ListView_Administrators, Contact_DetailView_Administrators, Contact_ListView_Users, Contact_DetailView_Users, etc. You may consider a specific naming convention, for example, to add a role name to the end of the view name. Use User and Admin user names with empty password to login into the application.



Implementation details:
There is E274.Module\Controllers\CustomizeViewAgainstRoleMainWindowController that tracks View showing using theXafApplication.ViewCreating event and replaces the default View's Id with a custom Id found in the Application Model by the role name. 

Monday, September 12, 2016

Why can a DetailView be not editable or display empty values?

This small thing may hit even experienced XAFers, so I want to post this tip here for the future. In fact, I created a corresponding KB article a few months ago, but forgot to promote it in my blog. So, here we go: https://www.devexpress.com/kb=T382896

SYMPTOMS
1. You are creating a new detail form via the XafApplication.CreateDetailView API in a Web application, but it does not allow users to enter any information; e.g., they can't write/select anything into/from lookups. The View controls also look "readonly" or disabled. The same code produces an editable DetailView in WinForms, though.
2. Same readonly View editors as in the previous point, but the controls do not display any values either + the code does not work in both WinForms and ASP.NET apps.
3. You are opening a DetailView of an object that was deleted by another user. This way, this behavior is normal and expected as removed data can no longer be edited.



SOLUTIONS
1. Make sure you have set the DetailView.ViewEditMode property to the DevExpress.ExpressApp.Editors.ViewEditMode.Edit value. For example, check the snippet from this KB Article: