Play (playframework.org) is a Java framework that makes it very easy to build web applications. Here I show how to build a CRUD web app in a way that reminds me of RoR or Grails. You only need to know Java to follow this example. Play’s website contains excellent documentation and I will not repeat them here.
Some of the material here was presented at CoJug on 2010.06.08. The CoJug presentation contained more than what is provided here, and was presented by Nilanjan Raychaudhuri and myself.
- Java 1.5 or higher installed.
- Play installed, remember to add Play’s location to the path.
- Eclipse 3.5 installed. (This is a personal choice, you may use any IDE or text editor).
This will be a simple CRUD application which manages the following entities:
- A group of companies.
- Each Company can have 0 or more Department.
- Each Department can have 0 or more Employee.
Create App’s Skeleton
- From the command line, navigate to the directory which will contain the new application.
- Run this command:
play new corporations
- You will be prompted to enter the application’s name, enter
- The above will create an empty Play application in the
- To try what you created, run this command:
- In your web browser, go to http://localhost:9000/
- You should get a page titled “Your application is ready !”
- This proves that Play is running and that you application has started.