Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Posts Tagged ‘MVC

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

ASP.NET FileUpload Revisited

with 2 comments

It is very interesting early on this week the HR’s guy come to my desk and told me he no longer be able to upload job’s annoucement attachment file ??! I said woh woh what you said? because we hosted the app and he successfully uploaded files many times.

After confirm that was the problem I run through the net to find what cause the problem why it just occur now? Well it must be something change along the windows update anyway I solved the problem and now the app back to it normal operation.

But I am glad to see the topic of File Upload has been digged up again let un-DRY it shall we?

Written by Chorn Sokun

June 29, 2008 at 12:00 am