PageMethods and Monorail Javascript Action Proxy

Recently I read an article about using Page Methods with ASP.NET Ajax (Atlas)

I’ve used this before on some projects, it’s very nice. You can basically use straight html with javascript, and make your ‘server-side’ calls via the proxy that Atlas creates with the page method.

Me being new to Monorail, I wanted to attempt the same. I figured I’d share my sample.

Monorail has a ‘Javascript Action Proxy’ article that I used to repeat the above.

My directory structure is:

Controllers
HomeController.cs

Views
Home
Index.vm (I’m using NVelocity)

In the controller I have the following ‘action’:

[Layout("Default"), Rescue("generalerror")]
public class HomeController : SmartDispatcherController
{

...

[AjaxAction]
public void sendAjax()
{
RenderText("Done");
}

...

}

In my view I have the following:

$AjaxHelper.GetJavascriptFunctions()
$AjaxHelper.GenerateJSProxy("myproxy")

function SendAjax()
{
var results = myproxy.sendAjax();
var devResults = document.getElementById("Results");
devResults.innerHTML = results;
}

Monorail will allow me to combine the benefits of using the C# language with a front-controller design and utilize existing javascript libraries. The helpers provide a mechanism to communicate from the controller to the view and vice versa.

ActiveWriter – Preview 3 Available

Gokhan Altinoren has released a new preview of ActiveWriter. ActiveWriter is a GUI class/mappings generator for ActiveRecord and NHibernate utilizing DSL tools. The generator supports drag and drop onto an interface.

ActiveWriter is a contrib project in the Castle’s repository:

http://using.castleproject.org/display/Contrib/ActiveWriter

From his blog, two main links:

Fresh from the trunk: ActiveWriter Preview 3

How to Generate NHibernate Configuration Using ActiveWriter

As always, it’s best to understand AR/NH before diving into the tools, but this tool is a good one 😉

CINNUG – June 2007 MVP Presentation by Scott Cate

The Cincinnati .Net Users Group meets on Tuesday, June 14th in Mason. I haven’t attended one of these meetings yet, but I’m interested in going.

Scott Cate is doing the presentation on MVP with .NET. I’m very curious how it relates to the MVP I’m using based on Billy McCafferty’s enterprise sample here http://www.codeproject.com/aspnet/NHibernateBestPractices.asp – I’ve been using this architecture on my current project and finding it to be very efficient and has good layering and separation of concerns.

It would be a big bonus if he mentions Castle’s Monorail as well – that is the direction I want to go with my future asp.net projects.

Monorail moves away from the WebForm leaky abstraction model and uses more of a front controller pattern with a HttpHandler handling the requests.  It still uses the underlying asp.net pipeline (note: asp.net vs. webform).  So you can use the ASP.NET Membership API, etc… Monorail has ‘filters’ to assist with this – very cool!
There are other MVC asp.net solutions that I know of : Subsonic and the Web Factory by the Patterns and Practices team. Subsonic looks interesting to me – the Web Factory I haven’t explored too much though. The solutions built by the P&P team seem ‘heavy’ to me – but they do include a IoC Object Builder. I’m biased though to the Castle’s Windor IoC container. It’s been easy to implement and lightweight – plays well with NHibernate, ActiveRecord and Monorail.

I’ll try to write up by thoughts after the presentation, I’m looking forward to this one! It’s always good to get different perspectives and to learn from others, otherwise I get stagnant in my thoughts 🙂

Vista – Presentation Mode

I must say, despite the Apple commercials, and some of my own negative thoughts about how Vista works…it has a few nice touches that I appreciate:

today I wanted to show a customer a demo of the web application we are building for them.  They had a nice monitor in the room, so I plugged  it into my laptop.  As I’m looking for the ‘toggle’ view switch on the laptop, next thing I know a window pops up asking me if I’m wanting to give a presentation on the monitor.  Wow – so, I hit yes.  It automatically adjusted the resolution, turns off the screensaver, and shows my desktop both on my laptop and on the monitor.
Later, I unplug the monitor, everything returns back to normal.

Just how it ought to work  :)  I was pretty happy about it

Arrival

Thanks to my coworker and friend, Ed Summerfield I’ve taken the leap to create my own blog. It could be perhaps because everyone on my spam list is tired of links of ‘hey, this is cool, check it out’!

My interest is in developing for the web – I’ve been doing most of my work with asp.net from the days of early beta. I’ve seen it come along and I’ve ridden with it through some ups and downs. At first I took my purely Microsoft route, datasets, typed datasets – objectdatasources – 3 tier models heavy with stored procedures, etc…

I’m not one to just stop and say, ‘ok that’s it, I’m set’. I like to keep pushing. I think the best thing that has ever happened was when I joined my current employer, SDS (Strategic Data Systems) – mostly because I met other, well experienced developers. The best discussions I’ve had are with the guys that had a java background. At first I was a bit bothered how they would ‘piece together’ a solution. At least that is how I initially viewed it. Now I see it differently. I think the first conversation was with my good friend Dave (Wanner) and Ping (Cui). Great guys on a gig in Dayton we were on. First Dave was pushing NUnit and testing on me, and Ping started by asking me about Spring.NET and Martin Fowler. I was immediately seeking out to understand more of this, in particular the whole concept of Inversion of Control.

One thing leads to another and I’m looking at Castle! If you develop in .NET you should really look at what Castle offers. It’s not just one solution, it’s a whole collection. Monorail, ActiveRecord, Windsor, etc…

Jimmy Nilsson’s book ‘Applying Domain-Driven Design and Patterns’ was a good jump start for me, both in terms of grasping what TDD is, and also about tools such as NHibernate. At first I looked for ways to ‘generate’ my NHibernate classes, etc… but then I found myself really wanting to understand the technology.

That all being said, my current project has given me a great opportunity to really work with these tools I love. My buddy Ravi can attest as I end a day saying ‘Man I love this stuff’! It’s a joy to code and build things in a way that is both challenging and fun.

I’m using an architecture that using NHibernate as the Domain, Windsor IoC container to handle the DAO/IRepository layers, and a good MVP design for the UI (I would have pushed for Monorail, but we have others not ready yet- and a strong desire to use the Telerik controls – but, I’m still figuring how to use it with anyway!). Billy McCafferty gave me the leap start I really needed in his article NHibernate Best Practices with ASP.NET, 1.2nd Ed.
Much more could be said, hence the blog. We’ll see how it goes – I don’t consider myself much of a writer. I prefer to be investigating technologies, but I have learned a ton from guys like Ayende, Jeremy Miller (his post on Orthogonal Code is a classic as far as I’m concerned – lol), etc… so perhaps I can pass something along to help someone else out while on my journey!