Open Source Support Is Not Just Code


As you know, I’m the author of MVC Turbine. Since the beginning of the project, I’ve received community assistance via code patches to address some issues or add features to the project.  Also, I’ve received non-code help from the community. For example, Hugo Bonacci (@hugoware) for donated his artistic talent and created these awesome logos for the project.  These logos adorn the CodePlex site as well as the Twitter account (@mvcturbine).

Most recently, I welcomed the help of Anthony from Sticker Mule to the list of contributors to the project.  Sticker Mule prints custom stickers starting at $69 for 100.  They aspire to be every developer's favorite sticker printing service. While building the Sticker Mule website, they leveraged Spree, an open-source Rails e-commerce platform to provide the features to their site.  Since open source helped them, they’re doing what they can to pay it forward. So they donated 100 awesome die cut stickers with the MVC Turbine engine logo to the project!

Check out their awesome work:

mvcturbine_diecutPretty awesome, huh? I would like to personally thank Anthony and Sticker Mule for this great addition to the project! So next time you see me in person, make sure to ask me for one!

Again, thank you Anthony and Sticker Mule for making open source a fun place to be in :)

Happy Coding!

author: Javier G. Lozano | posted @ Thursday, August 05, 2010 11:01 PM | Feedback (1)

MvcConf 2010


Recently my good friend and fellow C4MVC junkie, Eric Hexter blogged about an event the ASP.NET MVC community is putting together called, MvcConf.

What is MvcConf?

MvcConf is a online conference where you can learn about real experiences creating MVC applications as well about what the future holds for creating asp.net apps based on MVC.  We have scheduled community members to present on intro and advanced topics using MVC2 and we have some Microsoft product members who will talk about some of the new stuff coming out soon.

Why should I care?

If you’re interested in learning more about development with ASP.NET MVC, why not attend a free event (or session) that will aide that cause? Not only do we have community leaders on MVC but also members of the ASP.NET team, including the one and only PM for the product, Mr. Phil Haack!

You really have nothing to lose with this conference, well, except for some bandwidth since this conference is virtual and broadcast through Live Meeting. :P

Specific Details

So come on, check us out. Here’s the information that you’ll need:

When: Thursday, July 22 8AM – 5PM CDT

Cost: FREE

Where: Virtual (Live Meeting)

Register here: http://mvcconf.com/attend

We’re still working through the final sessions, so the schedule will be posted in a few days. Please bare with us as we coordinate these logistics :)

I’ll see you at MvcConf 2010!

Happy Coding!

author: Javier G. Lozano | posted @ Saturday, July 10, 2010 9:37 PM | Feedback (0)

MVC Turbine Resources


Recently MVC Turbine has had a lot attention, so I wanted to take the time to say “Thank You!” to those of you that have help promote it, use it, provided feed or giving it a look.

Artwork

In particular I wanted to say a HUGE THANKS to Hugo Bonacci (@hugoware) for donating his artistic talent and creating these awesome logos for the project. Thanks for putting up with my many draft changes and requests. The logos are awesome and I thank you for providing such a great asset to the project!

 

full-logo-large

(horizontal banner)

avatar-large(avatar/icon)

Development Team

Also, I wanted to list out a set of links to blog posts by my self and fellow MVC Turbine member, Darren Cauthon. Darren has provided a lot of great feedback, code and samples which makes the project a lot better.  Thank you Darren for your efforts!

Here are the links from Darren that showcase the extensibility that MVC Turbine provides to applications:

Also, here’s a list of some of the other extension projects that Darren is currently working on:

Podcasts

If you’re an audio learner instead of a visual one, then check out these podcasts in which, yours truly, talks about both ASP.NET MVC and MVC Turbine:

Future Plans

The plan of attack by the dev team is to provide better documentation as well as blog more about examples on ways to use Turbine to extend and power your applications (similar to what Darren is already doing). We want to make the portal site, http://turbineproject.com more than just a redirection to the CodePlex site.  At the same time, we want to roll in bug fixes, fluent registration features and MEF support into v2.2, so check out the GitHub repository for these changes.  Lastly, you can also download the MVC Turbine Project Templates for Visual Studio 2010 from the Visual Studio Gallery.

In Closing

Again, I want to say thank you for taking the time to check out the project and for all the help all you have provided. If you’re interested in helping out, reach out to me either via this blog or start a comment thread out in the Google Group.

Happy Coding!

author: Javier G. Lozano | posted @ Friday, July 02, 2010 12:35 AM | Feedback (0)

MVC Turbine v2.1 RTM


Last week, it was tweeted that MVC Turbine v2.1 had reached RTM.

Capture

Release Notes

The from the main ; the features it provides are (same as plus these):

  • Instance Registration to IServiceLocator
    • You can now add an instance of a type to the underlying container so you can address the single instance context.
  • IServiceLocator is registered into the container
    • This allows for components to take in a dependency on IServiceLocator and have it be injected at construction.
  • Batch registration with underlying IoCs
    • Using the batch registration for each IoC to make type registration more streamlined and performant. (StructureMap: Registries, Ninject: Modules, etc)
  • Added the GetUnderlyingContainer extension method to IServiceLocator to allow access for the underlying IoC implemenation.
    • If explicit access to the underlying IoC is needed, the method will query the corresponding member in the implementation and return to the caller.
  • Added extension methods to the ViewContext, and to access the current IServiceLocator without explicitly casting.
  • Property injection support for filter attributes
  • Global MVC filter support
    • MVC filters (,, etc.) can be registered directly into the IServiceLocator and will be applied across every request.

Visual Studio Integration

The Visual Studio Templates have been upgraded for VS 2010 and MVC2 and released to the

After some user feedback, these changes have been made to the code within the template:

  • Added new Services folder with implementation of IMessageService and MessageService to get the Welcome to ASP.NET MVC! message
  • For each IoC, implemented the injection of the container into the CSL as compared to manually doing it (v2 templates)

Project Discussion

All the source is available out on Github for you to check out or fork! Also, if you have any questions or would like to contribute feedback to the project, check out the MVC Turbine Google Group.

If you have any questions, please leave a comment out on the Google Group!

Happy Coding!

author: Javier G. Lozano | posted @ Tuesday, May 18, 2010 10:54 PM | Feedback (1)

A Simple JSON Model Binder


First of, I would like to give a huge thanks to Phil Haack for his awesome blog post, Sending JSON to an ASP.NET MVC Action Method Argument, which shows how really flexible the ASP.NET MVC can be. Also, I owe him a beer next time I see him for saving my behind and providing an actual solution to my original POSTing JSON Data to MVC Controllers post. 

Namaste, Phil!

Client-side JSON ‘Serialization’

In Phil’s post, he mentions that using a model binder falls short because of the lack of validation support:

There’s one key problem with using a model binder to accept JSON. By writing a custom model binder, you miss out on validation. Using his example, if you type “abc” for the Age field, you will get a serialization failure when attempting to serialize the JSON into the PersonInputModel object because Age is an Int32 and the serialization will fail.

He’s absolutely right and, as he mentions, you should use the JsonValueProviderFactory from the ASP.NET MVC 2 Futures library. Funny enough, as he was finishing up his blog post, I was working a simple JSON model binder to show how this is possible with what comes out of the box with MVC2. The source code for this sample is located here, http://github.com/jglozano/samples/tree/master/JSONModelBinder.

The interesting thing in both solutions, is that you do have to some work on the client side to take your javascript structures and convert them into JSON. Phil shows on his post how you can use a JSON plug-in for jQuery to accomplish this. If you read down in the comments, Dave Ward points out that we should be using Crockford’s json2.js to serialize (or stringify) your structure into valid JSON. Funny enough, while working on my sample I had bumped into this StackOverflow post that explains the reason to use Crockford’s script and quotes John Resig’s recommendation (add here for ease of read):

The second major feature of the language is the addition of native JSON support to the language.

I've been championing this move for a long time and I'm glad to see it finally arrive in a specification.

In the meantime PLEASE start migrating your JSON-using applications over to Crockford's json2.js. It is fully compatible with the ECMAScript 5 specification and gracefully degrades if a native (faster!) implementation exists.

In fact, I just landed a change in jQuery yesterday that utilizes the JSON.parse method if it exists, now that it has been completely specified.

There are two primary methods for handling JSON: JSON.parse (which converts a JSON string into a JavaScript object) and JSON.stringify (which convert a JavaScript object into a serialized string).

Once this piece is applied on the client side, there is still some work to be done server side.  For this piece, let’s assume we do not know about IValueProvider and the JsonValueProviderFactory and let’s explore the creation of a model binder (since I already have the code :P) and some of the issues of taking this approach instead of using the ‘baked-in’ pieces that Phil described.

JsonModelBinder and JavaScriptSerializer

I took a short look at implementing a JSONModelBinder and this is what I came up with:

The code is pretty simple and to the point, except for the interaction with the JavaScriptSerializer piece, which unfortunately does all the heavy lifting for the system. If you’re using .NET 4, the JavaScriptSerializer class has a Deserialize(String, Type) that returns an object of the specified type. However, in .NET 3.5, this method is not available since it’s marked as internal and the only option you have for deserialization is the DeserializeObject(String) method.

If you were to use this method for the example JSON data (in our case, {“Name”:”John User”, “Age”:”29”}) you will get an object of type IDictionary<string,object> as a result.  If you look at Jonathan Carter’s implementation, he leverages the DictionaryValueProvider within the JsonValueProviderFactory, which works great with the new model binding pieces since this type implements IValueProvider.

So, in order to get this piece to work with the type that’s specified via the ModelMetadata, I had to do some work with reflection and extension methods to expose the correct Deserialize method:

Unfortunately, not straight forward but it at the end accomplishes the sending of JSON data to a controller action:

CaptureWhere do we go from here?

Again, although this is functional, you will not get the desired results or leverage the full power of MVC2 new validation components. If you need to support this scenario, PLEASE USE the approach that Phil’s post outlines, it will save you headaches.

If you’re interested in looking at my code, it can be found here: http://github.com/jglozano/samples/tree/master/JSONModelBinder – also, you want to use this with .NET4, there are instructions within the model binder that tell you what to change in order to get things working correctly.

Happy Coding!

author: Javier G. Lozano | posted @ Friday, April 16, 2010 2:03 PM | Feedback (2)