By Sergey Zaitsev
DevExpess XAF is a very useful tool for creating rich line-of-business applications simply and quickly. However, there are certain issues developers can experience when creating complicated forms, especially when it comes to the form view customization. Being loyal XAF users ourselves and often working with large and complicated forms, we decided to cover some of the issues we face, as well as several ways to solve them.
One of the most common challenges we as developers faced was customizing the form's layout to the customer's business processes. There are several ways to address this issue. One way to address it is to use the Model Editor, when you just go to DashboardView -> DetailView -> Layout, and arrange the layout the way you need by dragging and dropping the elements of the form in the Customize Layout mode (invoked by a right click). No actual coding is required for this.
Figure 1: The Customize Layout Mode
Two other solutions to this problem involve basic coding, and they are: applying a DetailViewLayoutAttribute to required properties or using the Layout Control to customize the form view.
Another challenge is creating "role" forms that require minor differences when displaying a complex form for different user roles. Different views of the form can be developed by using the View Variants Module. It allows the developer to create various form views during the design time, and the end user&kmdash;to choose the required view variant at the runtime. In a nutshell, you'll just have to add a new ListView or DetailView node to the Views node for each view required, add view a variants node, and define the settings and properties as required.
Figure 2: The View Variants Module
One more issue a lot of developers face is business objects data extension in case one needs to show information not related initially to the business object type. It can be done using the Model editor: Views, without modifying the code, by the developer or application administrator. To do so, one has to add a custom calculated field to the form as follows:
- Invoke the Model Editor.
- Add a model member (BOModel | <Class> | OwnMembers | Add... | Member).
Figure 3: Adding a Model Member
- Specify its name and type values.
- Pass the expression that will be used to compute the field.
- Finally, restart the Model Editor and create a Detail View item or List View column for the newly added custom field (refer to Figure 2).
There are several possibilities to customize the view of complex XAF forms for all kinds of business purposes, involving various amounts of coding and thus applicable at various stages of application development or runtime.
About the Author
Sergey Zaitsev is the lead developer at Galaktikasoft. Having years of experience with XAF behind his back, he is an expert in solving all types of issues related to using this and other frameworks for business application development.