Posts

Showing posts from March, 2008

grails-selenium-0.4

This information is out of date - please see http://www.grails.org/Selenium+plugin Version 0.4 of the grails selenium plugin is now available. This version adds: scripts to create and run tests a postResults url for displaying the final test results Details are as follows: run-selenium Runs Selenium in the specified browser. Specify the path to your browser as a command line parameter i.e. grails run-selenium /usr/bin/firefox or, if the executable is on the path you would just need grails run-selenium firefox In your application.properties, you can specify: selenium.auto=true selenium.close=true selenium.multiWindow=true selenium.highlight=true selenium.resultsUrl=/your/url/here (defaults to ${appContext}/selenium/postResults) selenium.runInterval=1000 selenium.baseUrl= See http://selenium.openqa.org/installing.html (section titled Continuous Integration) for more information on selenium and continuous integration. create-selenium-test Generates a new empty selenium test. Supply th

grails-jsunit-0.1

This information is out of date - please see http://www.grails.org/jsUnit+plugin grails-jsunit provides an easy and convenient way to utilize the JsUnit framework to your grails application. JsUnit allows you to unit test JavaScript functions in a similar way to using JUnit for Java. To install the plugin, use: grails install-plugin http://www.javathinking.com/grails/grails-jsunit-plugin/0.1/grails-jsunit-0.1.zip This plugin adds the following new scripts: create-jsunit-test Generates a new empty jsunit test. Supply the path of the test you want to create, relative to 'test/jsunit/tests'. Example use: grails create-jsunit-test registration/mytest creates ${basedir}/test/jsunit/tests/registration/mytest.html run-jsunit Runs JsUnit in the specified browser. Specify the path to your browser as a command line parameter i.e. grails run-jsunit /usr/bin/firefox or, if the executable is on the path you would just need grails run-jsunit firefox In your application.properties, you can s

Firefox profiles

If you share a login with someone else (ie. family) Firefox profiles can be very useful. Likewise, if you are a developer and you have several different contexts or modes of operation, profiles can make life a lot easier. I use them at home with family members - you can set each person up with their own profile, so all you have to do is restart Firefox (rather than logging out out of the operating system and then back on as someone else). Firefox will prompt you - asking who you want to be right now. At work, how many times have you cleared all of your private settings while debugging, just to see if the problem is related to caching or some other previous state. Creating a profile is much easier - especially since you probably want to stay logged in to all of those websites you use every day. Just start firefox from the command line with the parameter '-profilemanager' - you'll be prompted with a dialog so you can mange your profiles. Read more about it here : http://www.

Looking for IT work in Australia? JobReel.com.au!

I'm currently looking for contract work, and all of the usual places offer vague job descriptions that makes it hard to differentiate one from the other. This makes it hard to decide which ones to apply for, and almost always mean that you end up applying for jobs that are totally inappropriate. Now there is JobReel.com.au - much along the lines of jobs.joelonsoftware.com , positions must display the employer. I'm still looking for a site that lets me specify location, price range, responsibilities and technologies - but JobReel is closer than any of the others, and from what I've seen so far, the job descriptions are more useful and realistic. It looks relatively new to the scene - good luck!

Ohloh.net

I just discovered http://www.ohloh.net/ - this is a great site, I think the easiest way I can describe it is by saying it is like linkedin.com , but based on opensource projects. You can create an account, and then add opensource projects to your 'stack'. You can: see geographically where people with a particular project on their stack are located add your experience to your profile to build your resume view statistics for different languages and projects. This is a very interesting site, and it will be interesting to see where it goes. Check out my profile .

grails-selenium-0.3

Version 0.3 of the grails selenium plugin is now available. This version: Adds GSP support for writing tests Fixes bug where hidden directories were shown as suites Fixes bug on windows with invalid URIs to html tests To use GSP to generate the tests, use the <sel:test> tag, followed by nested <sel:row> tags. <sel:row> can take either: one 'line' attribute where the command, target and value are pipe separated as per the pipe separated value files or separate 'command', 'target', and 'value' attributes. Because this is a normal GSP file, you have full access to the normal variables and you could call other classes for utility methods. An example GSP test: <g:set var="bookTitle" value="book0d"/> <sel:test name="MyTest"> <sel:row command="open" target="${request.contextPath}"/> <sel:row line="clickAndWait|link=BookController"/> <sel:row line="

grails-jttaglib-0.1

grails-jttaglib plugin is a small collection of convenience tags. The sample code below assumes you have a domain class that looks like this: class Book { String title="my new book" String content static def constraints = { title(maxSize:20) content(maxSize:200) } } When using these tags, you must have the following in the page - normally in the head block: <g:javascript library="prototype"/> <jttext:script /> textArea Creates a TextArea HTML element, where the maximum number of characters is limited by the constraints on the domain object, and tabs can be allowed if desired. Sample use: <jttext:textArea object="${new Book()}" name="content" allowTabs="true"/> <jttext:statusDiv for="content" /> The number of remaining characters available are displayed in the status div. If allowTabs is set to true, tabs can be entered in the text area. textField Creates a text input type usi

Regression testing grails plugins

For regression testing the grails plugins I've released, I have a shell script that: cleans up any previous runs packages the current code for the plugin OR downloads a release from my web site creates a new grails app copies preprepared resources into this new grails app installs the plugin Now all I have to do is run the application and test it through the browser (potential for selenium to help here?). This is great for testing the plugin against a new grails version, or just for testing code changes to the plugin itself. I put the script in <project_home>/test/regression/run.sh and the resources in <project_home>/test/regression/resources. The resources directory contains files like domain objects etc in the same directory layout as a normal grails project. This way I just need to copy the contents of the resources directory over the top of my newly created project. I should have written it as an ANT script though (what was I thinking?) - then it would be platf

Regression testing grails plugins

For regression testing the grails plugins I've released, I have a shell script that: cleans up any previous runs packages the current code for the plugin OR downloads a release from my web site creates a new grails app copies preprepared resources into this new grails app installs the plugin Now all I have to do is run the application and test it through the browser (potential for selenium to help here?). This is great for testing the plugin against a new grails version, or just for testing code changes to the plugin itself. I put the script in <project_home>/test/regression/run.sh and the resources in <project_home>/test/regression/resources. The resources directory contains files like domain objects etc in the same directory layout as a normal grails project. This way I just need to copy the contents of the resources directory over the top of my newly created project. I should have written it as an ANT script though (what was I thinking?) - then it would be

Allowing tabs in a text area

In addition to controlling the maximum number of characters in a text area , I also want to allow the user to enter tabs. But default, hitting tab would move out of the text area to the next control on the page. Overriding this behavior can be done by using the onKeyDown event controller so you can: check if the tab key has been pressed if it has, insert a tab at the current cursor location put focus back into the text area I've extended my little TextAreaTagLib to handle an 'allowTabs' attribute. Now you can allow tabs to be entered just by using allowTabs="true". I've also incorporated the work from the TextField modification so that the number of characters can be limited based on the maxSize constraint on the object. Sample use: <g:javascript library=”prototype”/> <jttext:script /> ... <jttext:textArea object="${new Book()}" name="content" allowTabs="true"/> <jttext:statusDiv for="content&quo

Allowing or denying self registration with grails-acegi plugin

The grails-acegi-0.2 plugin is great - it adds login, user management, and user registration capabilities to your application in seconds. However, I'm building a web application where I want to be able to let the deployment team decide whether users can register themselves or alternatively, have an administrator create users. I want provide these settings without the deployment unit (the WAR file) having to be modified. I currently have a properties file for each server (DEV, STAGE, PROD) which defines properties specific to the environment - such as the email server and username/password etc. In this properties file, I also have application settings which are relevant to that environment. So, this is a good place to define a property: myapp.registration.enabled=false Grails has an excellent configuration strategy, and in my applications Config.groovy all I have to do is specify the external config locations: grails.config.locations = ["file:${System.getProperty('myapp.pro

Maxlength HTML attribute for domain objects

With Grails domain classes, constraints can be specified - including the maximum size of a String. For example: class Book { String title static def constraints = { title(maxSize:20) } } When using 'grails generate-all' to create scaffolding, you'll notice that create.gsp and add.gsp hardcode the maxlength attribute: <input type="text" maxlength="20" id="title" name="title" value="${fieldValue(bean:book,field:'title')}"/> It is possible to directly reference the constraint, meaning that the maxlength attribute is not hardcoded - and thus only defined once (in the domain object): <input type="text" maxlength="${Book.constraints.title.getMaxSize()}" id="title" name="title" value="${fieldValue(bean:book,field:'title')}"/> In fact, we can go even further and create a tag where we pass in the object itself, and

Limiting the content of a TextArea

Being able to limit the length of the content entered into a TextArea can be useful for various reasons. Although not supported natively by HTML, you can achieve the same effect using Javascript - on KeyUp and KeyDown events, check the length of the textarea value and truncate if necessary. We can also display how many characters are remaining if we want to provide user feedback. Because I've used this technique in several Grails applications, I've created a simple TagLib - you may want to customize it to your requirements. To use it: include the prototype library with <g:javascript library="prototype"/> use <jttext:changeScript /> once on your page for the utility script define your textarea including the maxlength attribute with <jttext:textArea id="messageField" maxlength="20" /> use <jttext:statusDiv for="messageField" /> to display the status message showing how many characters are left So, a simple GS

mappings closure does not exists for class UrlMappings

I've just started working on a new grails application, and early in the piece I hit this error: 2008-03-05 18:39:20.715::WARN: Failed startup of context org.mortbay.jetty.webapp.WebAppContext@1fcb845{/jtchat,/home/prule/workspace/jtchat/web-app} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsUrlMappingsHolder': Cannot resolve reference to bean 'urlMappingsTargetSource' while setting bean property 'targetSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMappingsTargetSource': Cannot resolve reference to bean 'grailsUrlMappingsHolderBean' while setting constructor argument; nested exception is org.springframework.beans.

Sun Tech Days 2008

I'm currently attending the Sun Tech Days conference in Sydney. These events can be good for exposure to things not already on your radar, and also for catching up with colleagues you haven't seen for a while. Some of the presentations are online if you are interested. There is a session on 'Grails as an application framework: pros and cons' tomorrow - but so far there has no mention of Groovy or Grails (but plenty of references to JRuby, Ruby, Python, PHP, Javascript). Update 1 : Mike Cannon-Brookes presented Grails - this was a good introduction for anyone new to Grails. It appears he is very enthusiastic about it and Atlassian are using it to some extent internally.

grails-selenium-0.2

I've just uploaded a new version of my Selenium plugin for Grails . You can download it from http://www.javathinking.com/grails/grails-selenium-plugin/0.2/grails-selenium-0.2.zip . The only significant enhancement is to support tests nested in directories. Now, the suite page displays a list of all of the directories in the tests location. The default (top level) suite shows all tests in all directories. You can click anywhere in this suite heirarchy to load only those tests in that directory. Let me know what you think of this implementation. There are probably several different ways to go about handling the directory structure, and this is just one implementation. I hope you find it useful! (for more complete information about this plugin, see grails-selenium-0.1 .