The final stage in the delivery of your Grails application is to deploy it to a stable production environment, running in a hosted servlet container and against a permanent database that will not be cleared out every time you restart or re-deploy the application. You will see just how simple it is to package a Grails project into a deliverable and set up the Grails configuration for a production environment.
Once the application is up and running in a production environment we will briefly introduce some next steps that may worth investigating to learn more about working with Grails.
Now that you have finished the implementation of your application it is time to look at the code and see what can be pulled out into a separate component for reuse on future projects. The feature that stands out as being most reusable is tagging. This feature will be useful on many different projects. Simplifying the implementation of tagging for future projects by using a plug-in will be a great benefit. In this chapter you will see how to:
Create and package your own plug-in Enhance the plug-in using dynamic method support in Groovy and Grails
After our last increment of providing editable in-line tagging, the users have been making good use of the application. There are now hundreds of posts and quite a few files in our application. Sometimes activity has been so fast that users have reported their messages are getting lost and people aren't seeing the information they need.
It is great news that our application is being used so much, but we need to address some new user goals that have arisen due to the usage of the application. Namely, to easily search for past messages and keep up-to-date with the increased levels of activity.
It sounds like our users need to be able to search the content of the application, and given the high frequency of messages they would probably benefit from some sort of unobtrusive notification system for new content: an RSS feed springs to mind.
We have also received some requests to send messages into the application via email. Who knows where else we will need to receive data from in the future? We had better put some web services onto the application to allow other applications to add content in the future.
We are going to enhance the user experience of our application using AJAX and Rich Internet Application (RIA) frameworks. We will see how Grails provides built-in support for AJAX, and then introduce a plug-in that provides a number of components to leverage popular user interface design patterns. The enhancements we will implement in this chapter are:
Allow tags to be updated through AJAX. Automatically suggest existing tags when a user is tagging content. Use a tag cloud to filter content by tags.
Over the last few chapters we added the ability for users to upload and share files with their teammates. As with messages, files are displayed on the home page in the order they are added to the system. Currently all messages and files are displayed on the home page. Over time, our home page is going to become rather large and unwieldy. We need a users home page to show only the files and messages that they are interested in. To do this, users need to be able to tag their content.
We will implement a simple tagging solution, restructure the home page and then add some new pages to the application for viewing all messages and files.
The new Grails concepts that will be introduced in this chapter are:
Working with inheritance in the domain classes, and which strategies GORM supports for persistence. Using polymorphic queries over a domain inheritance hierarchy. Encapsulating view-rendering logic in GSP templates. How to manipulate collections with the Groovy methods collect and sort.