XAF - 5 - Go do it! Action types and options

XAF Team Blog
26 May 2008

This is post no. 5 in the mini series "10 exciting things to know about XAF". You can find the announcement of the series here.

As soon as you've written some application specific business functionality, the next important step is to make it available to the end user through the application UI. For this purpose, XAF supports Actions, which are represented by UI elements, depending on the target UI of course.

Simple functionality will sometimes live in the business classes themselves, and the easiest way to make this accessible through the UI is to create public methods in the classes and decorate those with the ActionAttribute. XAF will then create an instance of the SimpleAction type for you, together with some framework stuff that you'd otherwise have to create yourself. Using named parameters of the ActionAttribute, you can configure quite a few of the properties that the resulting SimpleAction has.

However, using the ActionAttribute gives you only so much flexibility, and in many cases it doesn't seem like the right solution to have more complex code live in public methods on a particular persistent type. In these cases you must create actions yourself in one or more controllers. XAF currently knows WindowControllers and ViewControllers, both of which can be easily created using Visual Studio templates that are installed with XAF (note that Actions are usually UI independent, so you should add your controllers to the UI independent xxxx.Module project in your solution!). The controllers can be used for many different purposes, some of which require you to write code and override methods from the base classes. In the case of actions you'll have to use design surface though, so bring it up with a double-click on the controller entry in Solution Explorer. In the Visual Studio toolbox you will then find the (currently four) different action types that XAF installs.

One of the most important things about these standard action types is that they all offer a variety of options that make them much more versatile than you'd think at first glance. Here's a summary of the four types -- this documentation here is actually very good, read the whole page carefully to pick up all the details. Especially don't skip the part about the members of the ActionBase, since it describes what you need to know about properties like ConfirmationMessage, Category and others!

  1. The SimpleAction is visualized as a Button and it "simply" invokes its Execute event, from where you can call your business logic.
  2. The SingleChoiceAction displays as a combo box or a tree. The latter can be used to display hierarchies of menus, where each entry is an executable element in its own right. With the combo box display, the action allows the user to select one from several elements (the docs call this an "operation mode", which captures the idea quite well).
  3. With the ParametrizedAction, the user can enter information in a text editor before invoking the action. A search function would probably be the best example for what this looks like -- the standard search functionality that XAF applications contain is implemented like this.
  4. Finally, the PopupWindowShowAction is the most complex and flexible type, as it brings up a window containing a standard XAF view before the action is executed. There's a special event that allows you to customize the view so it displays the exact data you want.

The tutorial application has examples for most action types, and it also gives information about other important details, like how to disable an action selectively.

That's it for today, about actions. This is a very important part of XAF, and also one of the more complex ones. As you might have noticed, most of links in this post go back to our product documentation -- there are a lot of details about actions, and I strongly advise you read up on them to see what the framework offers in this regard.

Tags
3 comment(s)
Anonymous
10 exciting things to know about XAF - eXpress App Framework Team

Pingback from  10 exciting things to know about XAF - eXpress App Framework Team

22 August, 2008
Steffen Dr. Uhlig
Steffen Dr. Uhlig

Dear XAF team,

The link target of "how to disable an action selectively" is missing.

4 October, 2011
Dennis (DevExpress Support)
Dennis (DevExpress Support)

Hello Steffen,

Thank you for the heads up! We appreciated that. I have found out that this link was referring to a help article that changed its location to documentation.devexpress.com

I have updated the blog post.

In addition, I suggest you check out two more help articles:

community.devexpress.com/.../best-practices-of-creating-reusable-xaf-modules-by-example-of-a-view-variants-module-extension.aspx

www.devexpress.com/kb=K18119

I hope you find this additional information helpful.

10 October, 2011

Please login or register to post comments.