Monday, 24 December 2007

BrowserShots - browser testing

Testing websites in all of the different browsers across all of the different platforms is no easy feat, and not always possible. I stumbled across BrowserShots which, given a web address, will produce screen shots of your website as they appear in different browsers on different platforms.

This easily lets you see how your site is rendered. Although there are still other aspects you might want to test, having access to these screen shots is fantastic.
Posted in

Thursday, 6 December 2007

404 with Grails

Grails allows you to specify a custom 404 page simply using the UrlMappings.groovy class:
class UrlMappings {
static mappings = {
"500"(controller:"errors", action:"serverError")
"404"(controller:"errors", action:"notFound")
}
}

This allows you to direct to a controller where you can then forward to a view:
class ErrorsController {
def serverError = {
render(view:'/error')
}

def notFound = {
render(view:'/notFound')
}
}

I started off with a simple view using the 'main' layout:
<html>
<head>
<meta name="layout" content="main" />
</head>
<body>
Page not found!
</body>
</html>

But for some reason, the layout does not get applied. I haven't dug to the bottom of this yet, but I have found a work-around:
<g:applyLayout name="main">
<body>
Page not found!
</body>
</g:applyLayout>

Now the layout is applied and the page looks like I would expect.

The error page for '500' is fine, it only seems to affect the 404 page.

(Grails 1.0-RC1  & Grails 1.0-RC2)