Click here to Skip to main content
15,884,473 members
Articles / Programming Languages / C#
Tip/Trick

15.2 What's New for XAF

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
29 Nov 2015CPOL4 min read 19.5K   1   4
What brings the 15.2 release for XAF (win) developers

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

Introduction

As an active developer for over 15 years, I have seen a few frameworks pass by, each having their advantages and disadvantages… A few years ago, I was given the opportunity to introduce .NET in a company that decided it was time to migrate from Delphi to .NET.

Although I realized that it was not a trivial task, I knew where I was going. XAF presented to me a number of features and out of the box functionality which gave me a head start. Continuous improvement over the years has brought us today to 15.2.

Let's have a look at what 15.2 has up its sleeve for us.

Areas of Focus

Due to the nature of the projects I'm involved in at the moment, the primary focus will be Winforms and EF, however some improvements for web applications are worth mentioning here.

What's New

ASP.NET Maps Module

The new Maps modules allows us to visualise any data on map.

So if I would like to show the revenue for the worldwide stores or point out on a map where it's located? The maps module will be able to assist you on this.

Image 1

Just a little code needs to be written to customize the underlaying dxMap;

C#
using DevExpress.Persistent.Base;

namespace DevExpress.ExpressApp.Maps.Web.Controllers {
   public class MapCenterController : ObjectViewController<ListView, Store> {
       protected override void OnViewControlsCreated() {
           base.OnViewControlsCreated();
           ((WebMapsListEditor)View.Editor).MapViewer.ClientSideEvents.Customize = GetCustomizeScript();
       }

       private string GetCustomizeScript() {
           return @"function(sender, map) {
                  map.option('center', 'Brooklyn Bridge,New York,NY');
                  map.option('autoAdjust', false);
                  }";
       }
   }
}

Validation Module (Win + Web)

The built in validation has always been a strong point of XAF, There are not many scenarios that are not covered by the built-in. Up to 15.1, the validation was triggerd when saving changes or manually when the validate button was pressed. In 15.2, for a subset of validation rules, validation occurs immediately after input focus changes. Important here is that Rules for immediate validation does not require any additional data to be collected from the server.

Following rules can be used for immediate validation:

RuleRequiredField

Demands that the Property has a value.

RuleRegularExpression

Validates the value via a regular expression.

RuleStringComparison

Validates the value via a string value compare (Contains, EndsWith, Equals, NotEquals, StartsWith)

RuleValueComparison

Compares the value of e.g. date or an int property (Equals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, NotEquals)

RuleRange

Checks if a value is with a specified range.

Immediate validation will cause the red error icon to popup if a property does not meet the rules applied to them.

Image 2

Detail View Layout

As always, there are a number of updates that contribute to the common good.

Many of us prefer to use the designer (Model Editor) but others rather do it in code... as of now, the detail view can also be modified via Code using the DetailViewLayout attribute.

It's just as simple as this:

C#
public class Contact {
 [Browsable(false)]
 public int ID { get; private set; }

 [DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
 public string FirstName { get; set; }

 [DetailViewLayoutAttribute(LayoutColumnPosition.Right)]
 public string LastName { get; set; }

 [DetailViewLayoutAttribute("FullName", 0)]
 public string FullName { get { return FirstName + " " + LastName; } }

 [DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
 public string Email { get; set; }

 [DetailViewLayoutAttribute(LayoutColumnPosition.Right)]
 public virtual Contact Manager { get; set; }
 [DetailViewLayoutAttribute(LayoutColumnPosition.Left)]
 public DateTime? Birthday { get; set; }

 [FieldSize(FieldSizeAttribute.Unlimited)]
 [DetailViewLayoutAttribute("NotesAndRemarks", LayoutGroupType.TabbedGroup, 100)]
 public string Notes { get; set; }

 [FieldSize(FieldSizeAttribute.Unlimited)]
 [DetailViewLayoutAttribute("NotesAndRemarks", LayoutGroupType.TabbedGroup, 100)]
 public string Remarks { get; set; }
}

Image 3

Reset View Settings

One of the advantages of using XAF is the option available to the end user to customize views and layouts. From now on, users can restore to the default settings with only a click of a button.

Image 4

Mind the Gap

While XAF was initially only available with Xpo (the DevExpres ORM), currently EF is supported as well and from my point of view, the GAP is closing fast... :-)

One of the many improvements in 15.2 gives a good example of this.

As an example we will have a look at querying using the ObjectSpace.

Before 15.2, if we would like to linq, we would need something like this:

C#
ObjectQuery<Payment> query = 
((EFObjectSpace)View.ObjectSpace).ObjectContext.CreateQuery<Payment>("Payments");

object obj = query.Where<Payment>(p => p.Hours == 4).FirstOrDefault();

When using Xpo, we would be able to do:

C#
XPQuery<Payment> query = Session.DefaultSession.Query<Payment>();

object obj = query.Where(p => p.Hours == 4).FirstOrDefault();

Both different approaches but with similar result.

As of 15.2, this has been implemented in the IOjbectSpace interface and therefore an identical approach can be used both for Xpo and EF.

C#
var query = ObjectSpace.GetObjectsQuery<Payment>();

object obj = query.Where(p => p.Hours == 4).FirstOrDefault();

For many of you, this might not be a big deal but for me, this makes a difference... KIS.

UX Web Enhancements

In 15.1, the templates were optimised for touch support, in version 15.2 this has been improved and found ready for use in production environments.

Not really using it at the moment but you can read all about is here. The following screenshot also gives a good idea what it is all about.

Image 5

Why DevExpress?

If you wonder why DevExpress makes a diffierence in my projects, let me explain by a simple example:

Back when I started my last big Xaf project, EF was not supported as it is today, however with the excellent DevExpress support, I was able to incorporate our legacy databases into the XAF Framework. Multiple databases were not supported by Xaf and therefore I presented them my requirements, shortly after, the solution (see schematic below) was implemented followed by a blog post that you can read here.

Image 6

Wrapping Up

The tip has mainly focussed on XAF, DevExpress 15.2 Universal has much more to offer us. I really enjoyed writing this tip and I hope you find it useful! If not, please let me know!

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer 3Way
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Gittum30-Nov-15 0:07
Gittum30-Nov-15 0:07 
GeneralRe: My vote of 5 Pin
Michael Bogaerts30-Nov-15 0:46
professionalMichael Bogaerts30-Nov-15 0:46 
GeneralRe: My vote of 5 Pin
_Nizar30-Nov-15 3:58
_Nizar30-Nov-15 3:58 
GeneralRe: My vote of 5 Pin
Michael Bogaerts30-Nov-15 4:16
professionalMichael Bogaerts30-Nov-15 4:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.