Search This Blog

Friday, December 30, 2016

A WinForms example for collapsing/expanding layout groups and persisting their state


As you probably know, the New Web UI was recently enhanced with built-in options for this scenario. Today, I have updated the https://www.devexpress.com/kb=S135134 thread with a WinForms solution:


Please don't hesitate to write to us about each use case scenario that requires additional code to adjust the layout controls to better meet your business needs. My team and I will be more than happy to research them and see how to manage this situation better at the XAF or DevExpress component level. For instance, here we are thinking about providing platform-agnostic Application Model extensions for managing this task for Windows and the Web.

Thursday, December 29, 2016

A custom XAF PropertyEditor example based on the WinForms TimeSpanEdit component

As you know, XAF is very flexible and provides many ways of integrating custom controls for various scenarios; e.g., where something is not covered by the default controls pack: Concepts > UI Construction > Using a Custom Control that is not Integrated by Default

As far as our framework development flow is concerned, it is absolutely natural to perform this sort of customizations, and this extensibility was baked in from the very beginning for XAF users. For instance, there is a built-in WinForms TimeSpanPropertyEditor class for representing and editing System.TimeSpan type properties in the standard delivery:

        public TimeSpan TimeSpanProperty {
            get { return GetPropertyValue<TimeSpan>("TimeSpanProperty"); }
            set { SetPropertyValue<TimeSpan>("TimeSpanProperty", value); }
        }

Technically, our TimeSpanPropertyEditor just wraps a TextEdit descendant from the XtraEditors Library and provides a custom mask for it. One may want to use another visual control for the same task (e.g., the TimeSpanEdit control from the same XtraEdititors library) and that is quite easy to implement in XAF. You can implement a custom PropertyEditor as per  Concepts > UI Construction > View Items > Implement Custom Property Editors


Monday, December 19, 2016

What is New in Help in XAF v16.2

As you probably know, in addition to the new great features the version 16.2 introduced, there are also various improvements to the learning materials that will allow you get the most of DevExpress products and become a better developer. The XAF documentation changes are listed below. I highlighted the topics I personally like or value the most in yellow. I would also greatly appreciate it, if you tell me about your favorite topics in comments!



The good news is that there are even more documentation updates currently in the works, and hopefully, I will be able to announce them to you soon.



How to view and edit only time values without the date part

I would like to promote a new KB article on integrating the WinForms TimeEdit and ASP.NET WebForms ASPxTimeEdit components in XAF:



My team and I would greatly appreciate it if you leave comments on whether you experienced similar tasks in the past and how you were solving them, or if you remember any difficulties with these solutions/maintenance.




Friday, December 16, 2016

Displaying the currently logged user name and photo near the Log Off Action (UPDATED)

We continue to evolve our framework and save time to its users by removing routine work for the most popular customizations like this one. Now in the New Web UI, an image associated with the current user is displayed at the top right corner of the application page when the IModelApplicationWeb.CurrentUserDisplayMode is set to Image or CaptionAndImage.

To provide an individual image for each user, do the following: 
 - Declare a property of the MediaDataObject type in your User business class.
 - Apply the CurrentUserDisplayImageAttribute attribute to the class and pass the property name to it:

[CurrentUserDisplayImage("Photo")]
public class MyAppUser : DCUser, IXafEntityObject, IObjectSpaceLink {
// ...
public virtual MediaDataObject Photo { get; set; }
// ...
}



The result is demonstrated in the image below (look at the top right corner):



The table below demonstrates the effect of different CurrentUserDisplayMode values.

Monday, December 12, 2016

Implementing State Machines at the Business Object vs Controller levels - YOUR FEEDBACK IS NEEDED!!!

I wanted to seriously question the current approach for declaring state machines in code using the StateMachine<T> class and IState/IStateMachineProvider interfaces (Predefined State Transitions Created in Code) and hear what you think of it in general. The main reasons behind this interest are the limitations this originally implemented approach has compared to other available solutions and hence associated support costs.



"Yet Another Controller"© 
In fact, in certain scenarios, creating a custom Controller with the SingleChoiceAction Action or a set of SimpleAction Actions can be simpler and more straightforward than defining a coded State Machine at a domain level. To give you a concrete example of such an alternative solution, check out this Controller that eventually does the same thing as the code in the original documentation article above, but with old-good SimpleAction objects manipulated on View and other suitable events. You can find another example with a SingleChoiceAction in this test project (it's from this SC ticket, so process it with the Project Converter tool first). Even though the alternative Controller-based approach requires more code, it allows you to provide a more granular control over created states and their visual representations. It is cleaner and easier to understand/extend for other business requirements, because it is your own code that uses only the basic XAF APIs.


Implications of using the questioned approach
Contrary to that, the questioned approach is really a bit shorter with the help of 'state', 'transition' and 'state appearance' abstractions defined near your business class, but everything has its own trade offs.

Wednesday, December 7, 2016

50 shades of grey or thoughts on making the XAF Web UI closer to its clients

Last week, I posted a case study on the New XAF Web UI from our DevPark customers, which caused another wave of feedback on the subject in our team blog, Support Center, social networks and in private discussions with passionate users. All of this was very much appreciated. In this post, I want to address some of the hot points raised as well as communicate our plans regarding this Web theme evolution. 

First, let me provide a little more background on the new web style. Originally, the XAF theme was designed and implemented bearing both hand-held touch devices and desktop browsers in mind. The new design fully reflects our vision of modern web interfaces and was created in close collaboration with our lead UI designer Mike, whom I respect a lot.  He also made up our company web sites, as well as a ton of other DevExpress desktop, web and mobile products and the ASP.NET themes in particular. Being derived from the Moderno theme, the XAF theme and the ideas built in it were  later reflected in newer themes like Moderno and iOS.

Like with any new thing in the world, when this XAF feature was first presented, there were (and still there are) "haters" and supporters who have their own values  and arguments. For instance, for ones it may be a positive change (e.g., "The new web style with its larger UI elements has also allowed us to rethink the whole UX concept and focus on the application data and functions that matter for end-users most of all"), while for others the same goodies may be not desirable (e.g., "Currently I develop LOB applications where these larger UI elements are not very well suited at all (screens with lot of info)..." or "my ideal UI is like the 75% zoom view of the current new UI"). Similarly, some may not like grayed icons or miss the old theme chooser, while others may truly love the current single theme with its large space, increased fonts and editors, collapsible layout groups, emphasis with capital letters and other essential attributes of the new web style. That is totally understandable, and we appreciate each side.  It is also clear that everyone's client needs for a line-of-business web portal may differ a lot and require different tools or customizations. Like I recently commented in the blog: "There is no "one size fits all" product/theme/whatever and as developers we sometimes need to customize things to meet our client's needs better. For instance, large UI elements can be made smaller, white colors can be made gray using CSS and other techniques."

The latter does not mean, however, that the development of this theme is frozen and we do not want to better meet varying customer needs. Ideally, and at least for the most typical tasks, it must be equally suitable with little or no customization for both an HTML/CSS newbie or a professional web master easily locating and changing required DOM element styles in the Developers Tools window of a favorite browser (learn more...).

Thus, we always listen to each user feedback and are constantly improving the theme according to the most popular requests.  Just to give you a few recent examples: there were a good number of requests to simplify the process of adjusting the New Web UI to match corporate colors. With v16.2, this process became much easier with the new options for changing the base color and font in code or configuration files of your app. Our XCRM.Web demo now contains a custom color/font scheme picker to demonstrate the use of these new release capabilities:

Object reference not set to an instance of an object. Part 2.

Before you get totally overwhelmed with the upcoming major v16.2 release (learn quick about XAF bits there), I want to further discuss troubleshooting errors while debugging your app, which is something any developer has to do regularly regardless of the used development tools.

Problem
If you have followed my blog for a long time, you may recall my first post devoted to this problem.
In short, it talks about debugging and analyzing exceptions in Visual Studio or looking into the built-in XAF log file for them. More information on the subject is also available in the online documentation at Concepts > Debugging and Error Handling
Unfortunately, we still receive quite a lot support calls with just this meaningless screenshots like " Object reference not set to an instance of an object" or similar without any callstacks, inner exceptions, loaded assemblies or any other meaningful diagnostic information that would allow us to help users in the most effective manner. Since such a screenshot does not provide any opportunity to the author or us to learn about the underlying cause of the error, an unnecessary clarification turn around and an accompanying delay always occurs in this case... This is certainly bad for both sides and thus is something we seek to avoid.

Possible solution
With v16.2, XAF WinForms apps will display a better error dialog while you are debugging your app:


We have not integrated a similar thing in the Web UI yet because the ASP.NET platform already provides quite a rich error page where the original problem was less noticeable, at least according to our internal figures.

Notice that the extended error form now  not only displays the top-most error message, but also shows the full call stack for you to research or copy to the DevExpress support crew, if necessary. At the bottom, there is also a link to the new help article describing the most common troubleshooting techniques that should help you save time and hunt "bugs" more effectively. In the majority of cases, these pointers should be sufficient to either research/fix your own custom code or submit an effective ticket to the Support Center, if the underlying issue has something to do with DevExpress routines.

This dialog should NOT appear when no debugger is attached to your app, e.g., when your end-users use your app in production - the former dialog will be shown there to avoid any possible confusion concerning technical details, as in previous versions.

Your feedback is needed!
We hope this will help our users and us to eliminate unnecessary delays and speed up overall problems troubleshooting in Visual Studio. As always, we are also looking forward to hearing from you on this small, but necessary service feature. For instance, to better communicate to developers that it is for development time only, we are also thinking about appending something like " (Debugging...)" to the form title, near the app name or adding some clarification tooltip on mouse hover. Or, is it already clear enough? Please let me know what you think. 
I also welcome other thoughts on solving the original problem in case we overlooked something.

Wednesday, November 30, 2016

How long since you have seen the "Dictionary already contains ClassInfo ..." error for the Model Editor?

Old XAFers can remember this old sporadic issue caused by a Visual Studio bug that could not be fixed on the IDE side for years (learn more...). We were frustrated by it no less than our users, and this April (15.1.11+, 15.2.8+, 16.1+) we finally found a way to bypass this nasty behavior of an internal IDE assemblies cache on our side by changing the process of  loading assemblies at design time. This was quite a risky change, but so far our testing of many projects under various circumstances went well. We also have not received user reports on the original problem or other side effects with our designers since then (more than 8 months).



That said, I wanted to explicitly clarify with the XAF community whether it is really gone after our changes or not. Please leave a comment below on whether you have seen this error with the latest XAF versions OR you already cannot recall when it occurred last time. If this still bothers you, I would kindly ask you submit a ticket using the Support Center and attach a project where this behavior is stably reproducible, exactly as this kind guy did in the past.

My team and I look forward to hearing from you!

Tuesday, November 8, 2016

How to show a specific View at application startup, right after the logon window or after loading the main window

I have recently updated my old KB article with several solutions and wanted to bring this for your information:


Here is the information on typical scenarios to get a better understanding of where this article can be applied: 

"One may want to show a dialog view at startup (after logging in). Typically, this view appears after the successful logon and allows a user to select or edit personal or global settings such as current password, company, currency, language, etc. Also, it may be often required to display this View as modal before a user can access the navigation menu or any other forms in the application. In other scenarios, it may be required to display a kind of notifications popup right after loading the main window, with unread messages, active orders, etc."





As always, it would be great to hear whether you are already using these techniques (specify approach #) in your XAF apps or you had to invent new solutions for a similar task. I am looking forward to hearing from you in the comments.


Monday, October 17, 2016

Welcome the EnableMultipleBrowserTabsSupport feature toggle for an XAF Web app - YOUR FEEDBACK IS NEEDED

Starting with v16.1.8+, we have made improvements for a quite popular ASP.NET scenario - working with several independent XAF views within tabs of the same web browser instance. Previously, it was not easily possible as the XAF web site stored the information about the current main window within the ASP.NET session between requests (learn more...). Technically, it still does, but now each loaded web window has a unique identifier by which all its requests are correctly routed on the server.

Now, with the new EnableMultipleBrowserTabsSupport feature toggle for your Web application, you can, for instance, include hyper links to two different XAF views into a customer email, and clicking these links subsequently would result into opening two separate browser tabs with the ability for an end-user to work with them independently.


To test this functionality in your Web project, do the following:
1. Install this hot fix build (or any other v16.1.8+ build when the link stops working);
2. Modify the YourSolutionName.Web/Global.asax.cs file to set the static WebApplication.EnableMultipleBrowserTabsSupport  property to True in the constructor or the Application_Start method. For instance:

namespace XCRM.Web {
    public class Global : System.Web.HttpApplication {
        public Global() {
            DevExpress.ExpressApp.Web.WebApplication.EnableMultipleBrowserTabsSupport = true;

So far, our tests were pretty stable, and we have not found any issues in standard XAF Web scenarios. We still want to collect more feedback and hear from you about how this works in your real projects. The more scenarios we cover at this stage, the better for the product. Take special note that this will still be in the preview state in XAF v16.1. If all goes according to plan and if nothing serious is found, this functionality will be officially released in the upcoming 16.2 build, which should be out around early December.

UPDATED:
See the http://dennisgaravsky.blogspot.com/2017/01/follow-up-on-enablemultiplebrowsertabss.html

Thursday, October 13, 2016

How to map Actions to a certain RibbonPage and RibbonGroup via the Application Model

This is my second post about advanced ribbon menu customizations in XAF WinForms apps. This time I want to repost two possible solutions for the aforementioned task after reviewing and updating the code of one good (and never old - Hi, Noxe!:-)) customer recently. This work was done after an interview about my Simplifying customization of Action controls - YOUR FEEDBACK IS NEEDED! post. Take a look at it if you haven't yet. 


Long story short, refer to the https://www.devexpress.com/kb=S134617 ticket and find two possible Controller implementations. Even though the first one (RibbonFromModelWithEventController.cs) requires more code to implement, I like it more, because it does not require you to create an Action Container node manually in the Model Editor. With the first one, you just specify the TargetRibbonPage and TargetRibbonGroup properties for a required Action under the ActionDesign node and you are done:


In any case, I suggest you play with both implementations and watch the attached video to determine what is more suitable for you. I look forward to hearing from you in the comments section or in the Support Center, as always.


I do not want to focus much on the Controller code itself, just want to note that there we extended the standard IModelAction interface corresponding to the ActionDesign | Action node and then handled these new options in our code. This is one of my favorite Application Model features, which is also truly loved by our customers. In fact, everything you see in our framework is built using the same simple principle: you have certain UI metadata or settings store and have some Controllers in modules that create/customize visual controls accordingly. To learn more about this, refer to the Concepts > Application Model > Extend and Customize the Application Model in Code article in our online documentation. This is a really cool feature and it can help you create a more reusable code.

Wednesday, October 5, 2016

How to place all nested View commands into the main ribbon and activate them based on the selected layout tab

My next two posts will be devoted to advanced ribbon menu customizations in WinForms, which become much easier to implement with the introduction of the new Ribbon and Standard templates (WinApplication.UseOldTemplates = False) back in v14.2 and also API changes in the recent XAF versions.

The current post is about mapping ALL Actions from the nested Frame toolbar into the main ribbon menu by creating a separate page. It is planned that when you activate a certain nested ListView within a layout tab, its related View commands will be activated in a separate ribbon page as well (context-dependent commands). This somewhat exotic approach was requested a few times by different customers and is likely dictated by users who have a habit of using only the main ribbon menu, i.e., without moving the mouse to the bottom context.

The two pictures showing how it was before and after making necessary code changes + a video showing everything in action are worth a thousand words in communicating this effect in the real app.
Context-dependent Actions in ribbon

Friday, September 30, 2016

How to find and deactivate a problematic Controller "on the fly" via an application UI for troubleshooting purposes

I wanted to repost a troubleshooting tip our old XAFer and MVP Dave Hesketh has kindly provided in the Support Center today. BTW, Dave also provides XAF training and custom development services, based out of Ontario, Canada, so this may be not the last thing you would want to learn from him and his website

So, let me focus on the problem and solution he described at https://www.devexpress.com/kb=T433881 and also also quickly show it all in action with one of the XAF demos:

"I have come across a few scenarios where something seems to be slowing down an XAF solution and it is tough to determine where the issue exists. This can then lead to hours of tearing out controllers to try and determine if one is problematic.

To make this process easier, I have created a module that you can add to an XAF solution to Enable and Disable controllers on the fly.

Once you add this module to your solution, you will find the "Show Controller Settings" action in the Tools menu. In the dialog that appears, you can enable or disable any controllers you wish, or click the "Disable Custom Controllers" to disable non-DevExpress controllers (A good starting place). 

Please note: Once you enable or disable controllers, you must re-open a view for the change to take effect. 
This solution has been tested on existing Win Applications only."





I remember a couple of similar requests from other guys, and indeed, this dynamic exclusion of Controllers without recompiling and restarting the whole app can be helpful when researching certain complex problems like performance or behavioral/visual side effects. For many other cases, the built-in Diagnostic Actionapplication log files, and performance profilers would suffice pretty well. 

Anyway, let's check how to use Dave's module with our MainDemo.Win app. Consider the following steps:

Monday, September 26, 2016

How to skip the logon dialog when debugging or testing an XAF app with the security system enabled

Sometimes during active development, you may find yourself in front of the logon form entering user credentials again and again, and it may eventually become boring. This simple to implement tip will not only save you development time, but also irritation. I wanted to highlight this technique for everyone here after assisting my colleague in this SC ticket + because another customer also found this solution helpful. Since, I also remembered that we have been using a similar thing internally for the installation tests of our demos, I think it is definitely time to let the rest of the world know about this as well.



Steps to implement


1. The instructions below imply that you have already created an XAF WinForms or Web app with the Security module, and its SecurityStrategyComplex and AuthenticationStandard components either using the Solution Wizard or manually. You likely also created predefined users and roles in code or using the application UI at runtime. Consult with the XAF online documentation for more details.

Thursday, September 15, 2016

Simplifying customization of Action controls - YOUR FEEDBACK IS NEEDED!

As you know, XAF provides abstractions for common UI elements like list and detail forms, their editors, main and navigation menus, etc. that enable XAF developers to accomplish common tasks for several supported platforms with less effort. Today I want to take a moment of your time and focus on popular customization tasks related to Actions - typically abstract UI elements that allow you to perform specific operations in response to end-user manipulations.



For instance, the ActionBase class, which is the super class for all Action types provides many useful members like Caption, ToolTip, Shortcut, PaintStyle, Enabled, Active, etc. that help you care less of technical implementation details for each specific platform or situation, at least for the popular tasks these members were designed for. It is also super easy to manage these properties and events in code or via the visual designers like the Visual Studio component designer for Controller or our own Model Editor.




Current approaches for customizing Action controls

The above looks very well (and many XAFers expressed this is one of the things they love the product for) and we have always been trying to keep this promise when designing our framework:
common and simple tasks can be done easily, while any specific or complex tasks are technically possible

But what about the second part of this promise with regard to Actions in practice? To answer this, it is best to evaluate it yourself for various tasks. Our documentation and support knowledge base contains many code examples for customizing Action controls in various places of an XAF application, and I grouped them below for your review.

How to provide a specific View layout for users of certain security roles

I would like to quickly promote a recent update to our old Code Example in the support database: https://www.devexpress.com/example=E274
I hope you find this solution helpful. Let me know in case of any questions, suggestions or share your experience with other XAFers on how you are doing a similar task at the moment. Thanks!

Scenario:
This example demonstrates how to show a custom View against a role of the currently logged user. Custom Views were created and customized through the Model Editor for each role separately. For more convenience, custom Views have a name of a role in the Id attribute. For instance: Contact_ListView_Administrators, Contact_DetailView_Administrators, Contact_ListView_Users, Contact_DetailView_Users, etc. You may consider a specific naming convention, for example, to add a role name to the end of the view name. Use User and Admin user names with empty password to login into the application.



Implementation details:
There is E274.Module\Controllers\CustomizeViewAgainstRoleMainWindowController that tracks View showing using theXafApplication.ViewCreating event and replaces the default View's Id with a custom Id found in the Application Model by the role name. 

Monday, September 12, 2016

Why can a DetailView be not editable or display empty values?

This small thing may hit even experienced XAFers, so I want to post this tip here for the future. In fact, I created a corresponding KB article a few months ago, but forgot to promote it in my blog. So, here we go: https://www.devexpress.com/kb=T382896

SYMPTOMS
1. You are creating a new detail form via the XafApplication.CreateDetailView API in a Web application, but it does not allow users to enter any information; e.g., they can't write/select anything into/from lookups. The View controls also look "readonly" or disabled. The same code produces an editable DetailView in WinForms, though.
2. Same readonly View editors as in the previous point, but the controls do not display any values either + the code does not work in both WinForms and ASP.NET apps.
3. You are opening a DetailView of an object that was deleted by another user. This way, this behavior is normal and expected as removed data can no longer be edited.



SOLUTIONS
1. Make sure you have set the DetailView.ViewEditMode property to the DevExpress.ExpressApp.Editors.ViewEditMode.Edit value. For example, check the snippet from this KB Article:

Monday, September 5, 2016

About searching freelancers, programmers, consultants with the DevExpress expertise and XAF in particular


I have recently come back from a 3 week vacation on Crete and I feel in a good mood for blogging. BTW, in my first-time experience, this place has a plethora of sights for both active and cultural holidays, crystal clean sea, tasty traditional and sea food, fruits plus Greeks being very nice people all with a funny Tolis-like accent:-) - it will be the reason for my pleasant memories again and again.

Today, I want to cover a question which I periodically receive privately or in the Support Center:

"Can you recommend anyone that might be interested in working as a consultant/programmer to help us develop our XAF app?"


Well, there are surely many developers that can qualify for this, and the first and probably the best way of locating XAF freelancers (as well as freelancers for any other technology) is using specialized services like https://www.upwork.com and https://www.freelancer.com. I just picked the two ones from the top of my head, so there may be alternatives and you must learn more on them first. For instance, check these example queries:

Thursday, September 1, 2016

Minor usability improvement - Nullable values support for boolean property editors

In short, this feature was already supported by the underlying WinForms CheckEdit and ASP.NET ASPxCheckBox controls, but it required writing some custom code in XAF apps. Now this coding is no longer required for XAF users if they need a Nullable<bool> property.

Starting with v16.1.6, the two built-in XAF editors support boolean Nullable properties. In the UI, when the check box is used, nullable properties will be displayed using a third 'grayed' state. When a drop-down editor is used, an empty 'null text' item will be available. Technically, the PropertyEditor.AllowNull must return True for the aforementioned UI transformations to take effect.

Please see the following code examples and screenshots for more details:

        public bool? ThreeStateCheckBox {
            get;set;
        }
        [CaptionsForBoolValues("Checked", "Unchecked")]
        public bool? ThreeStateDropDown {
            get;set;
        }


Web

Windows


Simplifying the migration from SecuritySystemUser to the new PermissionPolicyUser API

We have recently prepared a KB article on the subject: How to use the new Allow/Deny permissions policy in the existing project and hope to hear your feedback on it and this new Allow/Deny security feature in particular. If you have not yet heard about it and its possible benefits for your project, I recommend you review the Concepts > Security System > New Security System > Permission Policies documentation along with a short overview video on our YouTube channel.



As a side note, a quite popular How to hide individual navigation items and groups for certain users example was updated to use the new PermissionPolicyRole class.

As always, our team is more than happy to learn more on how our security module can help your business better or assist in case of any difficulties. Feel free to contact us via the Support Center: https://www.devexpress.com/Support/Center/Question/Create  or in comments here.

UPDATED:
See also this post from our old customer http://www.codeproject.com/Articles/1153095/How-to-migrate-DevExpress-XAF-SecuritySystemUser-t  for an alternative migration procedure.

Wednesday, August 3, 2016

What is New in Help in XAF v16.1

As you probably know, in addition to the new great features the version 16.1 introduced, there are also various improvements to the learning materials that will allow you get the most of DevExpress products and become a better developer. The XAF documentation changes we are the most interested in are listed below. I highlighted the topics I personally like or value the most in yellow. 




The good news is that there are even more documentation updates currently in the works, and hopefully, I will be able to announce them to you soon. To give you a hint, improved window resizing mechanism for both Windows and the Web, improved concepts for showing Views, registering property editors are among the things you will be able to learn more about in the future.


Concepts and task-based help

Usability improvements to the Model Editor layout designer and more in XAF v16.1.5

The recently released minor update brings several small, but useful features I hope you and your end-users will appreciate.

1. The layout designer available in the Model Editor at design time and runtime now generates a layout very close to what you can see in the end app. In particular, being invoked for the WinForms modules or apps, it now generates real Property Editors (in the disabled state and with fake data) instead of equivalent text boxes or bricks. It also tries to take into account and visualize the most popular layout and other options like ToolTip, ShowCaption, etc. IMHO, the most useful thing here is that you can now customize embedded ListView elements or List Property Editors corresponding to collection properties much easier via the grid control, like you can already do under the Views | ListView | Columns node. Even though the layout designer invoked for Web modules will not display real Web controls, but rather their corresponding WinForms analogs, the overall development experience will be better than before.




Thursday, July 14, 2016

Can I connect an XAF application to a custom data source (Web service, OData service, NoSQL database, etc.)?

My colleague Michael and I have recently worked on the article clarifying the currently supported data stores for XAF, because from time to time we receive questions like the one above. Even though this is a very basic information, it is still worth checking out even if you already have some XAF experience. Please let me know if there are any questions on this.


XAF is a framework designed to visualize and work with data represented as business or domain objects. The object-relational mapping (ORM) concept is very important here as in our framework you should not normally think of database tables, stored procedures (SP), SQL statements, but rather operate data in an object-oriented manner. Check out the Business Classes vs Database Tables article and information about Domain Driven Design (DDD) to get more inspirations. To access and manipulate objects, queries for all CRUD operations are performed dynamically based on view properties via the IObjectSpace API in a unified way. This design implies certain requirements to the XAF application data source, and makes it difficult to use an arbitrary data service or a specialized database in this role.

Currently, XAF supports the XPO  and Entity Framework ORM libraries out of the box with the help of the XPObjectSpace/XPObjectSpaceProvider  and EFObjectSpace/EFObjectSpaceProvider APIs respectively. They allow connecting an XAF application directly to relational databases supported by these libraries. See the Database Engines Supported by XPO and Entity Framework Data Providers articles for more details.

Also, starting with version 16.1, we introduced the XAF Mobile (CTP) Application Platform. It exposes the XAF application database via the standard OData V3 service that can be consumed by the XAF mobile client, as well as by any custom client you may want to create. Refer to the FAQ: New XAF HTML5/JavaScript mobile UI (CTP) article for more details.


If data from any custom data source (even NoSQL) needs to be used in some XAF views (not all, because otherwise ROI from using XAF can be low), without replacing the main XAF application data store, non-persistent or POCO objects can be used to represent this data with the help of theNonPersistentObjectSpace/NonPersistentObjectSpaceProvider  APIs.  Non-persistent data is usually not queried from a database using your ORM data model, and this can be extremely helpful for analysis and reporting data obtained from dynamic runtime calculations, stored procedures, arbitrary SQL queries or third-party services. Also, such a non-persistent POCO class may be required if you want to display a standard XAF List or Detail View with temporary data generated in code or loaded from a custom storage; or display an empty View (dialog) and then process the user input. Refer to examples in the "Business Model Design - Non-Persistent Objects" part of the Task-Based Help topic for more details. Alternatively, you can display and manipulate any custom data with the help of non-XAF forms or fully custom user controls embedded into standard XAF views as described at eXpressApp Framework > Concepts > UI Construction > Using a Custom Control that is not Integrated by Default.