Autoregistration without Binsor

May 13th, 2008

On my Global.cs I usually have:

private static void RegisterWebComponents()
{
    container.Register(AllTypes.Of<SmartDispatcherController>().
        FromAssembly(typeof(HomeController).Assembly));

    container.Register(AllTypes.Of<ViewComponent>().FromAssembly(typeof(Global).Assembly)
            .Configure(
                delegate(ComponentRegistration reg)
                {
                    reg.Named(reg.ServiceType.Name);
                }));

}

To get Windsor integration:

First, make the Global implement the IContainerAccessor

public class Global : HttpApplication, IContainerAccessor

Then add a static field to hold the container

private static WindsorContainer container;

The App_Start/End and the IContainerAccessor implementation:

protected void Application_Start(object sender, EventArgs e)
{
    container = new WindsorContainer(new XmlInterpreter());
    container.AddFacility("mr", new MonoRailFacility());

    RegisterWebComponents();
}

protected void Application_End(object sender, EventArgs e)
{
    container.Dispose();
}

public IWindsorContainer Container
{
    get { return container; }
}

To Configure MonoRail using code

Make the global implement IMonoRailConfigurationEvents and implement the method Configure:

public class Global : HttpApplication, IContainerAccessor, IMonoRailConfigurationEvents
{
    public void Configure(IMonoRailConfiguration configuration)
    {
        // Configuring ViewEngine
        configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views");
        configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false));

        // You can configure other things, and hopefully in the future
        // we can expose a kind of fluent interface to guide you on this process
    }
}

VS.Net support for js libs

May 13th, 2008

What? I’m reading this and I cannot believe! I’m seeing jQuery intelisense in VS.Net or my eyes are tricking me?

I couldn’t find a list of the bugs fixed, but I hope the css editor was also fixed. It crashes on us quite regularly with “cannot read from shared memory” or something like that. Then decided to switch to standard text editor for css.

Well, THANK YOU people at building 42 and 31. Great stuff!

Categories: jQuery | Top Of Page | 1 Comment » |

MonoRail with RoutingEx on IIS7

May 9th, 2008

It takes some time to figure out how IIS7 performs its handler/module matching, and to realize that the ordered list not always reflect the real order - once you set up an order click on View Unordered List and back to View Ordered List to see if it really changed to reflect what you want.

And one complain: it would be a lot easier if IIS7 and their handlers/modules could work together to identify if the handler/module was able to deal with the request or not, this is especially true for the DefaultDocumentModule. More on that later

This is how the handlers should look (in the ordered view)

iispanel.png

Steps

First of all, I’m using Vista Ultimate, so from what I’ve read, the integrated mode doesn’t work yet, so fall back to Classic mode.

After creating the web site or virtual folder, go to Handler Mapping and

  • Delete the handler for static files Empirical reason, I can be wrong: I wasn’t able to re-order this one as it seems to inherit from a parent configuration, deleting it saves a lot of hair
  • Add a new Module Mapping, request path: *.*, Module StaticFileModule, Restrictions: File and GET verb. I call this one StaticF
  • Add a new Script Map, request path *, Executable aspnet_isapi.dll (the whole path), name: MR. On the restrictions, uncheck the Invoke handler only if request is mapped to (maybe you could mark Folder, not sure if IIS is going to check if the folder actually exists, that would be a problem)

Now order the handlers. In my case I have a default.aspx, so I make the .aspx handler the first one.

Then you, as you dont want MonoRail handling static content, you make StaticF the next one

Finally MR handler should handle the rest of the requests.

I struggled for some time to get the DefaultDocumentModule working. The problem is that it conflicts with MR handler in its restrictions. You basically want that it handle a folder request, and redirect to one of the default document (if found). What actually happens is that it will greedily take all requests. Leaving no room for MR handler. The fix for that is changing MonoRail routing to be able to handle empty folders requests and matching a PatternRoute, something that today is not possible.

Let me know if that works for you.

Any developer out there?

May 2nd, 2008

Just wondering: is there any developer that has Castle experience, understands Ajax, is keen to learn new stuff and lives in Brazil (doesn’t need to be in Sao Paulo) that wants to join our team?

If so, please contact me directly on hammett at castlestronghold dot com

Castle Workshop in London

April 23rd, 2008

I was asked to help in spreading the word about it, so here it goes.

Skills matter is going to host a free workshop on agile web development with Castle. I wish I was there, I love London - on summer time!

Gojko Adzic also blogged on what makes a good application framework.

Categories: Castle | Top Of Page | No Comments » |

Incremental development with Monorail

April 23rd, 2008

Just bumped into this. Great work, Ben.

Just personal preference-wise:

- I’d prefer not to use the BaseControllerTest class
- Instead of writing the form tags, I’d use the form helper: $Form.FormTag(”%{action=’save’}”) and $Form.EndFormTag(). Then you take advantage of automatic form field validation if you want.
- For actions that change things, I’d use [AccessibleThrough(Verb.Post)]
- I’d configure Windsor through code
- The mapper/wrapper sounds like iBatis. Why not using Repositories with Castle ActiveRecord?
- Instead of DTO you could use the domain class as a prototype. I think that simplifies the code.

The cool thing is that Ben knows TDD. He creates a dummy implementation, get the test passing, corner it, triangulate it, and then is forced to get rid of the dummy implementation. That’s the essence of “test-driven”.

The series is also a good way to compare MonoRail with MS MVC. The goals are the same, they just provide different ways to get the same result, up to you to use the one you like the most.

Now accepting donations

April 23rd, 2008

Let’s see how much the community likes Castle


Categories: General | Top Of Page | 9 Comments » |

Dual licensing

April 21st, 2008

Very interesting argument, especially the last sentence “By selling commercial licenses, we are able to staff a dedicated development team to ensure continued progress, quality enhancements and first-class technical support for developers using Ext products.”

Seems to go against the usual mindset of users that want everything for free, like using an OSS project was a favor to the creator.

Categories: OS | Top Of Page | 3 Comments » |

In vacation

April 17th, 2008

So my vacation was divided in two pieces this year. First I drove north, about 700km, to the country-side of Minas Gerais. Fantastic lakes and waterfalls. Awesome cuisine especially if you like fish.

Then I work for more two weeks on donjon, and began the second part of the vacation, driving way south - 1200km - to Gramado and Canela. So frigging cold here that you would believe it’s Brazil! Excellent cities, if you like warm clothes and chocolates you will be delighted — awful restaurants, though. On my way there I made a quick stop on Florianopolis — whatta beautiful city! Seriously, I’m considering moving there!

Gonna drive home tomorrow, felling refreshed. There a few dozens patches to be reviewed and applied to castle, and hundreds of unread e-mail waiting for me :-)

Categories: General | Top Of Page | 6 Comments » |

You know you’re doing too much javascript when…

April 11th, 2008

At very end of your page you see

var histManager = new CriteriaHistoryCoordinator(criteria);

viewMng.addObserver(new ViewManagerHistoryManagerObserver(viewMng, histManager));

criteria.addObserver(new HistoryCriteriaObserver());
criteria.addObserver(new CurrentSearchObserver());
criteria.addObserver(new CriteriaViewObserver(viewMng));