Silver(very)light
My friend Caleb Jenkins of Improving Enteprises spoke at the North Dallas .NET Users Group last night about Silverlight 2.0 databindings, styles and templates. Caleb is a fun, energetic speaker, the kind of guy you want to have on your team or have a beer with. He’s definitely gungho over Silverlight, but I’m still not getting very warm to it.
Part of my grief with Silverlight is the same I have with Flex. We don’t need browser plugins to build feature-rich RIAs. I will concede the vector graphics space to these two technologies, but that is a space I could care less about. All the applications I work on involve web-based CRUD of business data. HTML and JavaScript are just fine at doing those, and I actually think ExtJS still does a better job than either with the widgets on the page. And since ExtJS is simple JavaScript, CSS and HTML, it will work with all browsers, including the iPhone, today.
To set the record straight, I’m going to expand my .NET demo project into a full demo site so you can see what I’m talking about. I’ll publish the URL when I’ve pushed some code.
I toss out my congratulations to Caleb on his diet. He’s lost 16lbs in only three weeks and it has motivated him to blog about it. He’s even going to have a contest to give away an MSDN subscription tied to weight-loss, although I think he should just give it to me for mentioning him in my blog
Also, I haven’t mentioned Improving Enterprises before, but I should. They merit a blog post of their own, but for now I can simply say they are the best small technology consulting company in the DFW area. I do not know of any other organization with such a concentration of A-list talent and would highly recommend them to any organization that actually needs to get something done.
The Missing Linq
I’ve almost wrapped up porting my ExtJS demo application to ASP.NET. It has been pretty simple so far once I realized I was trying to make it too complex. After getting a handle on ASP.NET MVC, I realized I didn’t need to use WCF for the JSON calls. ASP.NET MVC is pretty slick and has excellent built-in support for returning JSON data via the JsonResult class and Json method.
For the data, I’m using a very simple database I called Demo which contains two tables, City and Country. They look like this:
I’m using Linq to SQL for data access, and everything was moving along quite nicely until I ran into a small problem. In the Java version of my demo application, I used server-side sorting for the grid. How this works is that when you click a column header on the ExtJS Grid, the data store makes an AJAX call to the server controller with the POST data containing two parameters. The sort parameter contains the name of the column in the data store that the sort should be based on. The dir parameter has either the world ASC or DESC, indicating the direction of the sort.
The method signature in my controller which catches this request looks like this:
ASP.NET MVC will automatically map the two POST parameters to the two parameters in the method, since they have the same names. Where I hit a wall though was with Linq.
One of the big design features of Linq is to provide a strongly typed interface for the query language. Since I wanted the orderby statement to be based on the POST parameter, I thought I could do something like this:
Noticing no red squiggles, I assumed this would work. But it doesn’t. The problem is Linq is strongly typed, so it won’t accept a string after orderby. Linq wants something like this:
This would be cool in normal circumstances, but since I need to vary the orderby based on the sort parameter, I would have to do a large if-then block with multiple Linq queries, executing the required one based on the incoming parameter. Since that sounded like a pretty stupid idea, I dug a big deeper.
After much searching, I determined that Linq, as implemented, can’t handle the dynamic queries. But fortunately some other very smart people created a work around in the form of an extension to Linq called the Dynamic Query Library. Scott’s article provides a pretty good introduction. All you need to do is include the Dynamic.cs file in the solution and add the namespace to the imports.
Using the Dynamic Query extension methods, I can now do something like this:
The Dynamic.cs adds a new version of the OrderBy method which takes a string parameter containing the name of the field to sort on and an optional sort parameter. No if-then loops from hell and no more hair pulling trying to find the simplest solution that works.
I would bet the Dynamic.cs stuff ends up in core Linq, as it is simply too valuable for situations requiring dynamic data access, like my ExtJS demo. It also provides similar support for strings to the other Linq commands.
Now that I’ve gotten past the ugliness, I’ll be able to wrap up my ExtJS demo application. I’m adding some additional features to it which demonstrate some of the coolness of ASP.NET MVC, so stay tuned.
The Future of Browsing
The big news today was about Google Chrome. Chrome is web browser built by Google based on Webkit that is going to be their way of finally killing off Microsoft. They actually created an online comic book to explain why they created Chrome and the technology behind it.
What makes Chrome special compared to Safari or Firefox is their JavaScript VM called V8. The V8 JavaScript engine provides JIT compilation of JavaScript code, so your JavaScript RIA applications run with blazing speed. ExtJS is incredibly fast in Chrome. Another awesome feature is the ability to create a shortcut to a page that actually is an application link. For example, here is Chrome viewing the ExtJS API documentation:
Notice the window decoration with tabs, navigation, etc… Selecting the Create Application Shortcuts option will create a Start Menu, Desktop and/or Quicklaunch shortcut to the page you are viewing. Opening the shortcut opens the page as a pseudo-application, like this:
This creates a kiosk-mode view, without navigation. This web page of documentation is now essentially a standalone application. Google obviously intends Chrome to be the primary client-side hosting environment for its web-based application suite. This is also really good news for folks using JavaScript for RIAs. With the V8 JavaScript VM, you can have JavaScript performance on par with what a plug-in can do, and thus don’t need the plug-ins.
When Chrome goes final, I don’t see why anyone would not want to use it. It is extremely fast, with a clean UI and will completely change peoples perspectives on web-based productivity software. ExtJS becomes stunning in Chrome, and I’d actually bet that Google buys ExtJS to use it as their main JavaScript library. The only question becomes Google motivations. Will they “not be evil” or will Chrome turn into adware/spyware. Time will tell, but I’ll be using it until I think it is evil
Back to Business
So I had to ditch my PHP mistress for a bit and come back to the real world. I spoke tonight at the Spring Dallas User Group, giving a presentation on the ExtJS JavaScript library and integration with Spring MVC. We had close to 20 people in attendance, which was more then I expected given the short notice.
Erik Weibust and I had discussed me presenting to the group several months ago. I orginally planned to present in July, but vacation plans got in the way of the meeting date. In the interim, quite a bit happened in the ExtJS world. The fallout from the change to GPL from LGPL had simmered down, and they released a new version.
The presentation went well. Some folks had worked with ExtJS while others were learning about it for the first time. In spite of the turmoil from the license change, I’m still very excited about it. The 2.2 release added some cool stuff and I’m looking forward to digging in to it on a project.
For those in attendance, or the simply curious, I’ve attached the presentation, sample project and my own Spring JsonView implementation. Note that for the sample project, you will need to download the ExtJS distribution yourself and place the contents of it in the web/resources/ext directory. I didn’t want to redistribute ExtJS in my sample.
JQuery…. in action
We finally started a somewhat meaty RIA-ish project at work. My original intent was to use ExtJS for the bling, but it wasn’t through the corporate approval process and the available themes didn’t match the desired corporate color scheme. So instead of ExtJS, we’re using JQuery UI 1.5.
So far, I’ve been extremely impressed. It does not have near the number of UI widgets that ExtJS has, but I haven’t needed them for this web project. One of the most impressive things about JQuery UI is how easy it is to theme. Some silly-smart folks over at Filament Group created an on-line theming engine for JQuery UI called ThemeRoller. With ThemeRoller, I can specify the RGB values to exactly match the desired corporate color scheme and even add some cool effects. There is also a great blog post on how to use the ThemeRoller theme to create your own components.
I still like ExtJS, but I think JQuery and JQuery UI are really starting to get a lot of traction. The ability to create custom tailored themes is pretty huge for corporate and custom development, and right now, JQuery has the leg up on ExtJS in this space.







