Showing posts with label MonoRail. Show all posts
Showing posts with label MonoRail. Show all posts

Friday, January 18, 2008

Extending MonoRail ViewComponent

Quick note before I leave my desk for a meeting

Always apply ViewComponentDetailsAttribute on your custom ViewComponent like this
[ViewComponentDetails(string name, string sections, Type CacheKeyFactory, ViewComponentCache Cache)]


This will prevent your custom view component name clash with base component name.
Okay ! got to go

Monday, December 31, 2007

Castle.MonoRail.Framework.IFilter - Part I

Today I would like to share some technique in using Castle.MonoRail.Framework.IFilter . I am a bit sad because it takes too much time for me to realize how useful, until I read between the line over and over again
Filters are executed before and|or after your actions. It is useful for security, dynamic content and to keep away repetitive code.
Keep away repetitive code is what I am tracing, let the hear the story shall we?

This happen with one of the real world project that I am working on Data Bridge like any other web application it need authentication and passing some user preference along each action (inherit from SecureController) to the view such as List, Add, Edit & Delete action & view.

This can be done using the following technique:

Create Filters\AuthenticationFilter.cs
public class AuthenticationFilter: IFilter
{
bool IFilter.Perform(ExecuteEnum exec,
IRailsEngineContext context,
IController controller){
if(!UserNotLogin())
{
Redirect("Login", "Index");
}
else
{
controller.PropertyBag["maxRow"] = GetUserMaxRowPreference();
... set more preferences as needed
}
}
}
Create SecureController
[Layout("default"), Rescue("generalerror")]
[Filter(ExecuteEnum.BeforeAction, typeof(AuthenticationFilter))]
public abstract class SecureController : ARSmartDispatcherController
{
}
SecureController is marked as abstract, prevent from direct use.

Using SecureController
public abstract class ProductController: SecureController
{
public void List()
{
}
}
Now view part: View\Product\list.vm
When render table I want to display miximum $maxRow rows.
See there is no code need to set preference in each action method, nice.

Monday, September 10, 2007

RoR on .NET: The Quest Bonus Stage

There is no hacking tricks, it all pure web oriented programming.
Stop buying the idea of desktop application on the web "WebForm".

It never been this easy to build cool ajax enable web app like this

and this:

To produce this effect using webform I would have to write a lot of code which pretend to be the best practice. Hell, this will not happen anymore thanks to MonoRail.

By take on the quest I had done a few interesting things:
  • Source code check out from svn & built
  • Write an article for the community
  • Apply it to real world application which is a web interface to link between NCDD legacy database application & Unicef Reporting Framework, it a long story those and you might not interest anyway :). Well, this is the most difficult part and I got a lot of pressure for the deadline however it keep my challenge awake

Wednesday, August 15, 2007

Life without intellisence

Without an intellisence feature my programming life become doom :( I just feel I need to get additional eyes to read between the line :))

Can you tell the different between these lines of code?

${Url.Link('Main page', {@controller='Home', @action='Index'})}
${Url.Link('Main page', {@controller:'Home', @action:'Index'})}

and these two:

<% component captureFor, {@Id: "head"}: %>
<% component CaptureFor, {@Id: "head"}: %>

At the end of the day it just make me laugh @ myself :))

Now that should be the first trick to get into the castle.
The next step is to keep searching for the Excalibor

Come with me @
http://www.castleproject.org ; http://using.castleproject.org

Monday, August 13, 2007

Excalibor Quest inside the Castle


Do you want to join my quest? here is the Castle and the map ...

Man I love this project, I hope you will love it too.
If you find that not enough to buy you in check my ideal bogger's Ayande.