Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

MR, View & Controller

with 4 comments

Before I walk my fellower into the Castle I do a quick introduction on MVC design pattern everyone seem to get a pretty good idea how each part (Model-View-Controller) suppose to works separately and in group.

After get into Castle MonoRail everyone asked me why do MR always require a view (*.brail, *.vm) for each action? The answer was by convention you need to have a view for an action to land. However you don’t need to have 10 views for 10 actions, you can programmatically choice which view to land your action. 

But how? let take a look at CreateUser action

public void CreateUser([ARDataBind("u", Validate = true)] User user){
  if (HasValidationError(user)){
    // you might want to tell end-user what errors are
    Flash["u"] = GetSummaryError(user);

    // with ability to make correction without re-fill the entire form right?
    // here what the magic
    // happy day, user can safely create

Line #09: it tells MR to use add.brail view template instead of landing on its default view create.brail 
Line #15: again if you don’t want to to land just fly to somewhere else; no one gonna complain you about that ;)

isn’t that cool? Until next time …

Written by Chorn Sokun

November 3, 2008 at 11:07 am

Posted in MonoRail, Tips & Tricks

Tagged with

4 Responses

Subscribe to comments with RSS.

  1. Great to see MR intro!
    1. Could you point me some tips why do you choose Brail view engine instead of NVelocity that is the default for MR?

    2. ASP.NET MVC is new, but it’s also good. So which one is the best?


    November 3, 2008 at 11:45 am

  2. I choice brail because of Boo it so easy to use and extend; and in the near future my DLR language of choice is going to be Boo. In term of ASP.NET MVC tell the truth I don’t touch it just yet; so I can’t judge it. However I am happy with MR and Castle stack I spend some much time and energy study the tool set so if you don’t mind about Microsoft Stamp on the framework I say MR; unless ASP.NET MVC come with with killing features to beat down MR then I will consider again :) But for new comer yeah, I believe ASP.NET MVC is more convenient to them because it integrate nicely with VS.NET and it is not just another demo app from Microsoft ASP.NET MVC is real.

    Anyway at the end of the day these are all just a tools right? use it wisely so you can go home early.

    Chorn Sokun

    November 3, 2008 at 12:12 pm

  3. Unfortunately, I don’t get good luck getting MonoRail template project in New Project window of VS2008. So I decide to export my working template project.


    November 4, 2008 at 9:43 am

  4. the best way to learn MR is to get down & dirty with the trunk, get it built it and hack it there so much fun.

    Chorn Sokun

    November 4, 2008 at 10:12 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: