Thursday, April 29, 2010

REST Client Firefox Plugin

So, I do a lot of work with ajax/json or RESTful services exposed to the an HTML/JS or Flex client. When testing such services, I find it very useful to develop and test them in isolation from the client to make sure things work as they should. Then I can wrap the service calls in whatever client logic is appropriate.

A great tool for quickly testing these services is the REST client Firefox plugin. It allows you to enter the HTTP method, URL, headers and a body then issue your request. You can examine the response header and body to make sure things work as they should.

If you haven't used this plugin and are doing this kind of development, give it a try. I think you will definitely find it a time saver.

Monday, April 26, 2010

Grails Breadcrumbs

So, I'm currently developing the next big thing on the internet -- a user-generated content site that monetizes through ads and print-on-demand merchandise sales! What, no look of astonished wonder on your face? You act like thats been done before or something.

Okay, well, it has. And I really don't want to get into the details of what makes this unique until its ready for launch. There will be plenty of time for that later. In the meantime, I do want to talk about the technology behind the website.

I'm using grails as the MVC/service/persistence stack, with a heavy dose of jquery on the client-side for RIA goodness. In the coming months, I'm going to be discussing these technologies, plugins built on top of them that I am leveraging, and then the actual custom code I've had to write in support of the site. So, without further ado, I want to discuss...

Grails breadcrumbs!

Grails has a wonderful plugin community that has written many, many plugins to speed up web-app development (more about this in future posts). With regards to breadcrumbs, there is a menus plugin that wasn't really going to suit my needs. It seemed to tie you to a general site navigation framework that wasn't going to work for this site. So I had to go about making breadcrumbs for myself, and this is how I did it:

  • Created a breadcrumb model

    • BreadcrumbMapping class that contains a URI pattern to match against a name or a name generator closure.

    • Breadcrumb class that contains the actual URI hit that triggered a mapping, a reference to the mapping, and a name generated from the mapping's name or closure.

    • Breadcrumbs class that is basically a stack of breadcrumbs



  • Created a grails filter for the breadcrumbs. This examines any URI requests, looks up the BreadcrumbMapping for it, and appropriately manipulates the Breadcrumbs instance in the user's session to give an accurate navigation path

  • Created a renderBreadcrumbs tag to output a breadcrumbs navigation path using links with each Breadcrumb's name and URI

This approach has worked well. The only downside to this point is that I am using regular expressions to do the URI matching. I would rather use whatever API is in place to do standard grails URL mapping syntax. If I can get that figured out, I will probably refactor this out of the site as a whole and release it as its own plugin. This is something that would definitely be generally reusable for sites that want to implement breadcrumbs without any specific navigation framework.

Does anyone have any ideas as to where the URL mapping code is in grails, and if its generally leveragable outside the URL-to-controller mapping features of the framework itself?

Sunday, April 25, 2010

ITS ALIVE

I started a blog.

And the earth shook.

Or perhaps I have indigestion.