Tuesday, September 8, 2009

Xaf tip #5 Running Controllers everywhere

I recently being asked a lot about a way of making Xaf front end (that is your Solution.Win,Solution.Web) able to host controllers. To many of them i answered that is not possible cause of the Xaf architecture but haven’t thought of it, It was a rushed answer. Anyway i do not have to make a lot of thoughts on it since my friend Panagiotis Kefalidis share that trick with us.

First lets give an example of why you want to run controller in your front end. Many licensing systems need to have access to your executable and through it to your main form in order to protect it. For Xaf the only way to get access to your form is through a controller.

So the trick is to fool Xaf front end to make it behave like a module. Modules are capable to run controllers. And how you can do that?

It is really easy all you have to do is to add a DevExpress.ExpressApp.ModuleBase derived class to your front end like

    public class MyModule:ModuleBase{
        
    }

then goto your WinApplication.Designer.cs

image

instantiate your module at your InitializeComponent method

image

and add it to application’s modules list

image

And you are done!!!!

See you at next tip

Technorati Tags:

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

5 comments:

  1. Do you have an example of this working?

    ReplyDelete
  2. Hey Gary

    It is as easy as I describe it above a sample for that would be too much

    ReplyDelete
  3. One of the most popular requests from customers is a widget type Dashboard. In XAF this is very difficult to do without a custom page. This might be something nice to include in expand.

    ReplyDelete
  4. I understand that an example is to much but still have trouble understanding what you mean with : "Many security systems need to have access to your executable and through it to your main form."

    What security systems is it that you are talking about?

    ReplyDelete
  5. @Martin I probably chose the wrong word. What I really want to speak about was licening and software activation systems

    ReplyDelete