Determine Why an Action, Controller or Editor is Inactive
- 9 minutes to read
When building an application, you may need to determine why an Action or Controller is not active (visible) in a particular Window. An Action may be deactivated or disabled for various reasons: Security System permissions, the current View is read-only, an inconvenient object type of the current View, and other specific parameters. The current View may also be made read-only for different reasons. A thorough debugging may be required to ascertain the actual reason. For this purpose, the XAF provides the Diagnostic Info Action. This Action shows a window with information on all Controllers and Actions loaded to the Application Model for the current View, and validation rules applied to the View. You can use this information to find issues and fix them. This topic explains how to add the Diagnostic Info Action to your application and use it to get this information.
- Enable the DiagnosticInfo Action
- Analyze the DiagnosticInfo Action Output
- DiagnosticInfo Reference
- Custom Diagnostic Information on Actions
#Enable the DiagnosticInfo Action
To add the Diagnostic Info Action to the UI, follow the steps below:
Open the configuration file of your application’s project. The name of the file depends on the UI framework:
- WinForms – App.config
- ASP.NET Web Forms – Web.config
- ASP.NET Core Blazor – appsettings.Development.json
Locate
EnableDiagnosticActions
key and set its value toTrue
to add the Diagnostic Info Action to the Application Model and show the Action in the UI.For WinForms and ASP.NET Web Forms:
<add key="EnableDiagnosticActions" value="True" />
For ASP.NET Core Blazor:
{ //... "DevExpress": { "ExpressApp": { "EnableDiagnosticActions": true } } }
The Diagnostic Info Action is implemented in the DevExpress.ExpressApp.SystemModule.DiagnosticInfoController
and belongs to the Diagnostic Action Container. The images below show the Diagnostic Info Action’s location on different templates.
- WinForms
- ASP.NET Web Forms
- ASP.NET Core Blazor
The Diagnostic Info Action is a SingleChoiceAction. When you click this Action’s item, you invoke a dialog window with the DiagnosticInfoObject_DetailView Detail View. The DiagnosticInfoObject.AsText
property contains information in XML format.
#Analyze the DiagnosticInfo Action Output
Follow the steps below to determine why an Action is disabled.
- Determine the identifier of an Action you want to debug. If the Action is implemented in your code, use the ActionBase.Id value. Otherwise, refer to the Determine an Action’s Controller and Identifier topic for instructions on how to get the identifier of a built-in or third-party Action.
- Click Diagnostic | Actions Info and search for the Action identifier in the output XML.
Look at the XML element that describes the target Action and its Controller. For instance:
<Controller Name="OpenObjectController" FullName="DevExpress.ExpressApp.Win.SystemModule.OpenObjectController" Active="True"> <ActiveList> <Item Key="View is assigned" Value="True" /> <Item Key="View type is ObjectView" Value="True" /> <Item Key="PropertyEditor has ObjectSpace" Value="True" /> </ActiveList> <Actions> <Action ID="OpenObject" Caption="Open Related Record" TypeName="SimpleAction" Category="OpenObject" Active="False" Enabled="True" AdditionalInfo=""> <ActiveList> <Item Key="Controller active" Value="True" /> <Item Key="HasReadPermissionToTargetType" Value="True" /> <Item Key="DataViewMode" Value="False" /> </ActiveList> </Action> </Actions> </Controller>
If the
Active
orEnabled
attributes for the Controller or Action element returnFalse
, look at each individual item under the nestedActiveList
andEnabledList
elements. TheKey
attribute of each property briefly describes why the Action or Controller is active or not. A superposition of all Value attributes for these nested items forms the resulting Active or Enabled value for the parent Action or its Controller.
#DiagnosticInfo Reference
When you select the Actions Info item, the invoked window displays the following information:
Section | Definition |
---|---|
Template | Specifies the current Window’s context name and Template’s type name. |
Template | Default | Specifies the name of the current Template’s default Action Container (see IFrame |
Template | Default | Lists the Actions registered in the default Action Container (see IAction |
Template | Default | Specifies an Action’s ID (see Action |
Template | Action | Lists the current Template’s Action Containers. |
Template | Action | Specifies an Action Container’s name. |
Template | Action | Lists the Actions registered in the current Action Container (see IAction |
Template | Action | Specifies an Action’s ID (see Action |
Controllers | Lists all Controllers loaded to the Application Model. |
Controllers | Controller | Specifies a Controller’s name and the Active state (see Controller. |
Controllers | Controller | Active | Allows you to compare the Controller. |
Controllers | Controller | Active | Specifies the key and value of an item from the Controller. |
Controllers | Controller | Actions | Lists the Actions contained in the current Controller (see Controller. |
Controllers | Controller | Actions | Action | Specifies the following Action details.
|
Controllers | Controller | Actions | Action | Active | Allows you to compare the Action |
Controllers | Controller | Actions | Action | Active | Specifies the key and value of an item from the Action |
Controllers | Controller | Actions | Action | Enabled | Allows you to compare the Action |
Controllers | Controller | Actions | Action | Enabled | Specifies the key and value of an item from the Action |
Controllers | Controller | Actions | Action | Items (for Actions of the Single | Lists items contained in the Choice |
Controllers | Controller | Actions | Action | Items | Item (for Actions of the Single | Describes an item: its caption, Active and Enabled states. If the item has a collection of nested items (see Choice |
Controllers | Controller | Actions | Action | Items | Item | Active | Allows you to compare the Choice |
Controllers | Controller | Actions | Action | Items | Item | Active | Specifies the key and value of an item from the Choice |
Controllers | Controller | Actions | Action | Items | Item | Enabled | Allows you to compare the Choice |
Controllers | Controller | Actions | Action | Items | Item | Enabled | Specifies the key and value of an item from the Choice |
The information presented in the invoked window when the View Info item is selected includes the following:
Section | Definition |
---|---|
Detail | Describes the current View. Writes values of the following properties. |
Detail | Allows you to compare the View. |
Detail | Specifies the key and value of an item from the View. |
Detail | Allows you to compare the View. |
Detail | Specifies the key and value of an item from the View. |
Detail | Allows you to compare the View. |
Detail | Specifies the key and value of an item from the View. |
Detail | Lists the Property Editors contained in the current View. |
Detail | Describes a Property Editor: |
Detail | Allows you to compare the Property |
Detail | Specifies the key and value of an item from the Property |
List | Describes the current List View. Writes values of the following properties: |
List | Allows you to compare the View. |
List | Specifies the key and value of an item from the View. |
List | Allows you to compare the View. |
List | Specifies the key and value of an item from the View. |
List | Allows you to compare the View. |
List | Specifies the key and value of an item from the View. |
List | Describes the current List View’s Editor (see List |
The information presented in the window invoked when the Rules Info item is selected includes the following.
Section | Definition |
---|---|
Rules | Lists all validation rules registered in the Application Model. |
#Custom Diagnostic Information on Actions
You can supply custom diagnostic information on an Action. To do this, use the ActionBase.DiagnosticInfo property. Its value will be assigned to the AdditionalInfo item within the Controllers | Controller | Actions | Action section. In the following code, the DiagnosticInfo property is specified for the SetPriorityAction from the SetPriorityController, which is implemented in the MainDemo (see Add an Action with Option Selection):
public partial class SetPriorityController : ViewController {
//...
private void SetPriorityController_AfterConstruction(object sender, EventArgs e) {
SetPriorityAction.DiagnosticInfo += "\r\n" + "Hello!";
}
// ...
}
The diagnostic info snippet below demonstrates the state of the SetPriorityController and its SetPriorityAction when a Contact is displayed in the main Window.
<Controller Name="SetPriorityController"
FullName="MainDemo.Module.SetPriorityController" Active="True">
<ActiveList>
<Item Key="View is assigned" Value="True" />
<Item Key="Activating is allowed" Value="True" />
<Item Key="!ViewChanging.Cancel" Value="True" />
</ActiveList>
<Actions>
<Action ID="SetPriorityAction" TypeName="SingleChoiceAction"
Category="RecordEdit" Active="False" Enabled="True" AdditionalInfo="Hello!">
<ActiveList>
<Item Key="EmptyItems" Value="True" />
<Item Key="Controller active" Value="True" />
<Item Key="ObjectType" Value="False" />
<Item Key="HideActionsViewController" Value="True" />
</ActiveList>
<EnabledList>
<Item Key="EmptyItems" Value="True" />
<Item Key="ByContext_RequireMultipleObjects" Value="True" />
</EnabledList>
</Action>
</Actions>
</Controller>
The SetPriorityAction is activated in the main Window when a Task is displayed and the diagnostic information above confirms that this Action is currently deactivated.