Monday, July 29, 2013

Creating object relationships using the application model

In next version of eXpandFramework 13.1.5.13 it will be possible to create associations between business objects. Let’s see in details how this will work.

1. Installation – Prerequisites

The runtime members can be found in the eXpand.ExpressApp assembly, therefore you need to install the XpandSystemModule. However because this assembly has platform specific versions you will not find it in the toolbox and you have to go for its win or web version which is XpandSystemWindowsFormsModule or XpandSystemAspNetModule. To see how easy it is to install the XpandSystemWindowsFormsModule watch the next video. Note that it is also possible to create object relationship for the web.

2. Simple association

In the next video you can see how we can create a relationship between two entities at runtime. To be more specific I will create a relationship between the TopicIcon and The Category business objects. I already have a sample application and logged in as the Admin user so the relationship I will create it will be stored in Admin’s user model. 

3. Creating the many part of the relation

In the next video instead of working with XAF’s default model editor, we will use the ModelDifference module. XAF’s Application Model is by design multi layered and the ModelDifference module exposes this functionality in a more business oriented approach. It is also faster to work with it because as you can watch in the video I only execute the save action without even reloading the model! Even if the ModeDifference module introduces the concept of application models, I am going to use again Admin’s model and I will create an Icons collection for the Category object and I will link the reference TopicIcon Category property I created in previous video. Note to install the ModelDifference module you need to go through the exact steps of step one but this time for the ModelDifferenceWindowsFormsModule.

4. Creating an Orphaned Collection

An orphaned collection does not participate in a relationship however it is possible to be filters. In step three I linked a TopicIcon with a Category and also added a TopicIcon to the same Category instance. Both TopicIcons were of Type Idea. Now I will create an Orphaned collection of all TopicIcons with Type Idea and I will add it to the Category_DetailView.

5. Distributing the Application Model

We already created our relationships in the Admin’s model. However, this means that they can be used only for the Admin user. To confirm this in the next video I will give Edit Model permissions to a normal user and I will login to explore his model. Then I will switch back to the Admin which has permissions to modify ModelDifference module objects. Next I will create a Role model by cloning one of the existing models. Finally I will associate the Role model with the users Role, I will merge it with the Admin’s model and switch back to the User to confirm that he also can see the same as the admin.

Forgot to mention that runtime member creation is now very fast thanks to Sandrowelter (see this thread in eXpand forums).

Happy XAF’ing to all!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, July 16, 2013

Runtime views created from business users

You all know the powerful Application Model Editor with the embedded layout control that allows view creation without any technical knowledge. However the Model Editor is so powerful that may be dangerous to allow access to everybody. A few years now in eXpand we have the XpandViewVariants module that allowed end users to build views without the model editor. This modules is based in XAF’s built-in ViewVariants module and the XAF team is constantly improving it. However eXpand resources are not so huge so our module was a bit outdated.

Today things changed, because I spend some hours to refactor the ModifyVariantsController and now can do magic. if you using eXpand you only need to install XpandViewVariants module, if not and thanks to XAF’s MVC architecture just grab the controller for eXpand’s online repository http://goo.gl/mnFR7 or even follow its history http://goo.gl/CPx5A.

Now simply watch the next video to see that this controller can do for you.http://screencast.com/t/nrELagRJBhY

P.S.: We really appreciate your input in our latest surveys we run for both XAF and eXpand. If you haven’t participate yet please see this post

http://apobekiaris.blogspot.ru/2013/07/poll-which-of-following-expand.html.

Comments as always in eXpand forums Smile, here a related thread http://goo.gl/cQ05p.

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Monday, July 15, 2013

Poll - Which of the following eXpand modules/features do you use most?

Our community project (www.eXpandframework.com)
is growing fast and thanks everybody for the contribution and trust! However in order to use our limited resources better and make some plans for the future I would to ask your participation in the following survey.
I would like to ask your input one more time in the following survey: Click here to take survey

Reminder: There is also a XAF related survey going on at http://dennisgaravsky.blogspot.ru/2013/06/we-are-currently-in-process-of-13.html.

Both are our tools to get direct feedback from all of you to improve our beloved XAF.

Thanks you all for your participation!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Anonymous authentication for XAF aps.net applications

As promised  in eXpand’s forums with next version of eXpand (13.1.5.8) you can enjoy anonymous authentication for your web applications!
The anonymous authentication functionality is embedded in Xpand.ExpressApp.Security.Web module. After installing this module you need to enable it and setup the anonymous username using XAF’s Application Model Editor.
image
It is possible and recommended to combine anonymous authentication with auto-authentication discussed in http://apobekiaris.blogspot.gr/2013/07/auto-authentication-rememberme-for-your.html. Note that the model of the previous post is refactored to allow each feature to work independently.
image
Next you need to configure XAF’s security system by setting up the Authentication and the LogonParameters as illustrated in the image bellow.
image

And finally you need to create the anonymous user and role in your ModuleUpdater.cs. For this and if your use XpandRole class I provided the next extensions methods (GetAnonymousRole, GetAnonymousUser).
void CreateAnonymousSecurityObjects() {
    var anonymousRole = ObjectSpace.GetAnonymousRole("Anonymous");
    anonymousRole.GetAnonymousUser();

    //add project specific permissions
    anonymousRole.SetTypePermissions<Category>(SecurityOperations.ReadOnlyAccess, SecuritySystemModifier.Allow);
    anonymousRole.SetTypePermissions<Topic>(SecurityOperations.Read, SecuritySystemModifier.Allow);
The GetAnonymousRole method will create a new XpandRole (if not exists) and will add two custom permissions the MyDetailsPermission that will hide MyDetails from anonymous role and the AnonymousLoginPermission. It is also possible to do the same using XAF’s UI as in the next image.
image
Moreover I want to mention that using XpandRole is not mandatory, I used it because of the built-in support for custom permissions. You may have your own implementation following for example How to: Implement Custom Permission, Role and User Objects so feel free to use them.
Together with the MyDetailsPermission I mentioned the AnonymousLoginPermission. This one is responsible for hiding the default XAF’s Logoff action and for providing a new LoginAnonymous action. So when someone visits your site and you use Xpand.ExpressApp.Security.Web with enabled anonymous access, by default XAF will authenticate the anonymous user you created in the ModuleUpdater, and with the LoginAnonymous action will allow authentication as provided by XAF.
image
That was it my friends! I hope you find this implementation easy to use and useful. For questions, feedback etc feel free to use eXpand forums.

Happy XAF’ing to all!

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Wednesday, July 10, 2013

Auto authentication + rememberme for your XAF web apps coming

In next version 13.1.5.2 of eXpandframework there is a new Security module for web (Xpand.ExpressApp.Security.Web.dll) that can automatically logon using forms authentication. It is based on the CanAutomaticallyLogonWithStoredLogonParameters functionality of XAF web apps.
Installation
To use it simply install the Xpand.ExpressApp.Security and use the XpandLogonParameters object in your authentication type
image
To enable this functionality as usual we need to use XAF’s Application Model editor.
image
As you can see in the image above it is possible to control the ticket expiration as well.
By default XpandLogonParameters will render a RememberMe checkbox
image
However again using Model Editor we can simply remove the RememberMe PropertyEditor and the auto authentication will work for any user logged in last!
image
Happy XAFing to everyone! and do not forget your input in our forums http://www.expandframework.com/forum/11-news/3452-auto-authenticate-and-remember-me.html#4007
P.S.: Here is the related code in our github repo http://goo.gl/XfIPC

If you like to see this feature in embedded in XAF please track http://www.devexpress.com/Support/Center/Question/Details/S171787

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

Tuesday, July 9, 2013

DetailView as a PreView in GridView

Recently I had the need to display a complex layout as a preview row in my AspxGridView. Instead of adding a nonpersistent property where I will construct the html I though it would be easier to simply use XAF’s ModelEditor to design a DetailView and then assign that in my preview row.

After one hour or less I ended up with this controller.

    [ModelAbstractClass]

    public interface IModelListViewPreviewRowDetailView : IModelListView {

        [DataSourceProperty(ModelViewsDomainLogic.DataSourcePropertyPath)]

        [DataSourceCriteria(ModelObjectViewDomainLogic.ModelViewsByClassCriteria)]

        [Category("eXpand")]

        IModelDetailView PreviewRowDetailView { get; set; }

    }

 

    public class PreviewRowDetailViewController:ViewController<ListView>,IModelExtender {

 

        protected override void OnViewControlsCreated() {

            base.OnViewControlsCreated();

            var previewRowDetailView = ((IModelListViewPreviewRowDetailView) View.Model).PreviewRowDetailView;

            if (previewRowDetailView!=null) {

                var gridView = ((ASPxGridListEditor) View.Editor).Grid;

                gridView.Templates.PreviewRow = new PreviewRowTemplate(Application,ObjectSpace,previewRowDetailView.Id);

                gridView.Settings.ShowPreview = true;

            }

        }

 

        class PreviewRowTemplateITemplate {

            readonly XafApplication _xafApplication;

            readonly IObjectSpace _objectSpace;

            readonly string _viewId;

 

            public PreviewRowTemplate(XafApplication xafApplication, IObjectSpace objectSpace, string viewId) {

                _xafApplication = xafApplication;

                _objectSpace = objectSpace;

                _viewId = viewId;

            }

 

            void ITemplate.InstantiateIn(Control container) {

                var templateContainer = (GridViewPreviewRowTemplateContainer) container;

                object obj = templateContainer.Grid.GetRow(templateContainer.VisibleIndex);

                var detailView = ViewFactory.CreateDetailView(_xafApplication, _viewId, _objectSpace, obj, false);

                detailView.CreateControls();

                templateContainer.Controls.Add((Control) detailView.Control);

            }

 

        }

 

        public void ExtendModelInterfaces(ModelInterfaceExtenders extenders) {

            extenders.Add<IModelListView, IModelListViewPreviewRowDetailView>();

        }

    }

In the image bellow you can see a ListView of DetailViews Smile

image

In next image you can see how simple is to configure this all thanks to XAF Application Model.

image

The controller of course now lives in www.expandframework.com and you can follow its history in our online repository.

http://goo.gl/oCJ1J

This is not a perfect solution, however it does its job. I also posted in eXpand forums where we can all discuss further improvements

http://www.expandframework.com/forum/11-news/3443-detailview-as-previewrow.html#3988

Subscribe to XAF feed
Subscribe to community feed

DiggIt!