Monday, September 20, 2010

Make your navigation behave

Xaf provides a very easy to configure navigation system and in this post i will speak about expand approach to make Xaf’s navigation system behave better than the one provided by default.

To enable eXpand extended navigation behaviour one can use the ViewShortcutProccesor attribute either at BO level or at View level as shown in the next image

image image

Now what this ViewShortcutProccesor can do to speed up your development?

  1. Navigate to a detailview using a ReadOnlyParameter

    image

    the above readonly parameter taken from eXpand feature center and is defined as

        public class ExternalApplicationKeyParameter : ReadOnlyParameter

        {

            public ExternalApplicationKeyParameter() : base("ExternalApplicationKey", typeof(Guid)) { }

     

            public override object CurrentValue {

                get {

                    return ((User) SecuritySystem.CurrentUser).Session.FindObject<ModelDifferenceObject>(

                            o => o.Name == "ExternalApplication" && o.PersistentApplication.Name == "ExternalApplication").Oid;

                }

            }

        }

     

  2. Navigate to a non persistent object detail view
    image
    the object can be designed as

        [NonPersistent]

        public class WelcomeObject

        {

        }

    or as

        [NonPersistent]

        public class WelcomeObject:XPBaseObject

        {

            public WelcomeObject(Session session) : base(session) {

            }

        }

  3. Browse objects directly from a detailview
    The navigation settings here are exaclty the same as the above but also the navigation actions of the detailview will be enabled, allowing you to navigate to the next record.
    if for the current type no objects are found a new one will be created
    image
  4. Navigate to a specific object/ collection of objects detailview
    Setting at ObjectKey the criteria of your choice  you can open a directly a detailview. If object not found a new one will be created again
    image
  5. Desing your navigation using class based attributes
    Using XpandNavigationItem you can design deep tree level menus by just decorating your class
    image
    the above declaration will create the navigation shown in the image bellow
    image
  6. Design time view cloning
    When building a real world application, most probably you are going to have multiple views for your object types. eXpand provides the CloneView class level attribute that can help you create cloned views at design time.

        [CloneViewAttribute(CloneViewType.ListView, "ConditionalControlAndMessage_ListView")]

        public class Customer : CustomerBase {

            public Customer(Session session) : base(session) {

            }

     

        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]

        public class CloneViewAttribute : Attribute, ISupportViewId {

            readonly CloneViewType _viewType;

            readonly string _viewId;

     

            public CloneViewAttribute(CloneViewType viewType, string viewId) {

                _viewType = viewType;

                _viewId = viewId;

            }

     

     

            public string ViewId {

                get { return _viewId; }

            }

     

     

            public CloneViewType ViewType {

                get { return _viewType; }

            }

     

            public string DetailView { get; set; }

        }

     

    the advantage of using CloneViewAttribute is that your cloned views are not created in the lastlayer, thus later changes on the view are noted easily . As you see in the next image only the NewColumn attribute is mark bold!!
    image 

Subscribe to XAF feed
Subscribe to community feed

DiggIt!
blog comments powered by Disqus