in
Forums
Blogs
Files
Devexpress.Com
ClientCenter
Support Center
DevExpress Channel

Gary's Blog

XAF Cookbook #1 – Quickly Create a Contact Management Application

Problem

You need to quickly create an application to manage Contacts. You want both win form and web form applications.

Solution

Use XAF to create the win form and web form solutions and sub class the built in Person class to create the Contact class.

Discussion

By default XAF creates both a win form and web form application out of the box. Create a new XAF application and give it a suitable name. Since a Contact is a “kind of” Person, subclass the built in Person class to create your required Contact class, adding any extra properties you require.

using System;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace XAFCookbook_001.Module {
    [DefaultClassOptions]
    public class Contact : Person {
        public Contact(Session session) : base(session) { }

        private string _SpouseName;
        public string SpouseName {
            get {
                return _SpouseName;
            }
            set {
                SetPropertyValue("SpouseName", ref _SpouseName, value);
            }
        }
    }
}

In this example I have added the extra property SpouseName to the Contact class (using the CR template “XPS”), you should add any extra properties required in the same way.

By default, the win form project is the startup project. Press F5 to launch the win form application. Note your Contact class has inherited the properties, and the view layout, from the Person class. Note also the addition of your SpouseName property.

Switch the startup project to be the web form project and launch the application once more. Note you have the same layout and functionality as you did in the win form application.

Technorati tags:
Digg This
Published Aug 29 2008, 03:21 PM by Gary Short (Developer Express)
Filed under: ,
Technorati tags: XAF, XAF Cookbook

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Verification code: Required
   
Add
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED