Search This Blog

Monday, June 26, 2017

AuditTrail - How to show the change history for the current object in a separate form instead of a nested ListView

I wanted to draw your attention to the scenario and solution in our Support Center, which were found helpful by at least 4 other XAF customers using XPO for data access. As you know, by default, we offer our users a solution based on the nested ListView, which is automatically generated when you declare a collection property like this one:

    public XPCollection<AuditDataItemPersistent> AuditTrail {
        get {
            if(auditTrail == null) {
               auditTrail = AuditedObjectWeakReference.GetAuditTrail(Session, this);
            return auditTrail;

The solution I am promoting allows you to keep the layout less complex and invoke this rarely used or quite advanced feature from a small PopupWindowShowAction showing a ListView:

It will be interesting to hear about your preferences in this regard. Please let me know in comments. Thanks!

Thursday, June 22, 2017

How to display another web site or custom HTML inside IFRAME embedded into an XAF View

I would like to share links to the solutions for ASP.NET WebForms apps allowing you to display arbitrary HTML content in XAF Views. For instance, one may want to use it to display HTML emails in a DetailView or load a complete third-party web site. Take special note that these custom solutions are NOT based on the built-in HTML Property Editor Module and its ASPxHtmlPropertyEditor that uses the DevExpress ASPxHtmlEditor control.

The T178588 ticket describes a very basic solution for displaying a static URL within a DetailView.
The T180499  ticket provides a more complex solution where HTML content is loaded dynamically from a business class property.

Both solutions are based on a very popular way to integrate custom controls in XAF - custom View Items. A custom ViewItem is often preferred over a custom PropertyEditor when you just need to display data without editing and other capabilities. Of course, you can choose from more integration options based on your exact business requirements: Concepts > UI Construction > Using a Custom Control that is not Integrated by Default.

It would be great to hear about whether you experienced similar scenarios and which solutions you are using for them in your Web app. Please let me know in comments to this post. Thanks.

While we are at it, it is worth noting that we do not support displaying an XAF Web app inside an IFRAME element by default.

Tuesday, June 20, 2017

Performance tuning of the saving/validation process using the PersistenceValidationController events

Regardless of how good and sophisticated your development tools are, real production use often imposes research and solving speed issues. In this tip, I will talk about tuning the Validation Module to do its best when saving a master object exposing  large collections of aggregated data. 

By default, aggregated objects are considered to be an integral part of a master object, and thus, they should be validated together with the master object, which may take significant time if you have hundreds or thousands of complex detail records. The entire detail collection will be loaded and validated in this instance.

The good news is that XAF is very flexible and has a customizable framework that provides many ways to intercept this validation process. 

Linking XAF security roles and Active Directory Security Groups by name

We have recently created a new help topic devoted to one of the popular scenarios our users described: How to: Assign the Same Permissions for All Users of an Active Directory Group. This topic demonstrates how to map XAF security roles to AD groups. When a user logs on for the first time, existing roles with names matching the user's AD group names are automatically assigned. If the user membership in AD groups was modified, the associated roles collection will be updated accordingly on the next logon. Take special note that the corresponding XAF security roles with required permissions and matching the names of AD groups must be created first!

This article also required for us to avoid confusion with the AuthenticationActiveDirectory component name, because it does not support Active Directory Security Groups out of the box.  What this component does is just allow logging by the currently logged Windows user automatically or without the logon form.  To initialize the created XAF security user record, the AuthenticationActiveDirectory authentication uses the WindowsIdentity.Name property of an object obtained via the static WindowsIdentity.GetCurrent method to get a user name in the DOMAIN\USERNAME format.

I want to point out one implementation aspect that might be unclear: why did we create a AuthenticationActiveDirectory descendant instead of handling the CustomCreateUser event, which looks simpler? The main reason for using the descendant is that with it, the synchronization of XAF security roles is easier to implement when AD groups are updated.

I hope you find this example helpful. Please let us know in comments if you experienced a similar scenario and describe how you are currently handling it. Thanks in advance!

Addition to the VisibleInXXX attributes family for controlling available types and fields in the application UI

With v16.2.6 and v17.1.3DevExpress.Persistent.Base > VisibleInReportsAttribute  can be applied to a business class property as well. When the VisibleInReports attribute is applied to a business class property, it specifies whether or not the target property is visible in the Report Designer field list.

BTW, with the introduction of the Dashboards ModuleVisibleInDashboardsAttribute was added as well. I hope you did not miss it as well.

Thursday, June 15, 2017

The recommended approach to hiding the 'Protected Content' columns and Property Editors is improved - YOUR FEEDBACK IS NEEDED!

I have recently updated the HideProtectedContentController code in the How to: Hide the 'Protected Content' Columns in a List View and Property Editors in a Detail View topic. The main change is that the HideProtectedContentController now checks if a visibility state for the target UI element is customized by existing Conditional Appearance rules before applying its own customizations.

void appearanceController_CustomApplyAppearance(object sender, ApplyAppearanceEventArgs e) {
    if(e.AppearanceObject.Visibility == null || e.AppearanceObject.Visibility == ViewItemVisibility.Show) {
        // ...

This prevents possible conflicts with existing appearance rules.

If you are using the HideProtectedContentController code in your projects, we would greatly appreciate it if you try the updated code and share your feedback here in comments.

Please note that HideProtectedContentController may make a negative impact on the application performance in complex scenarios.

Wednesday, June 7, 2017

XPQuery changes regarding non-persistent properties in v17.1

In version 17.1, we have improved error detection in XPQuery when non-persistent properties are used in it. Previously, such queries didn't work (either failed with various exceptions or worked incorrectly) and thus there were hidden errors in your programs. Now, we throw an exception that describes which non-persistent properties are used in XPQuery to help diagnosing these errors. If such properties are used intentionally, consider implementing them using PersistentAliasAttribute or adding the ToList method call to explicitly process these properties on the client side.

Refer to the KB Article for examples and more details.

FreeImages.Com/sanja gjenero