Getting Started with Roo
Josh Long, Steve Mayzak
Format: PDF / Kindle (mobi) / ePub
Spring Roo goes a step beyond the Spring Framework by bringing true Rapid Application Development to Java—just as Grails has done with Groovy. This concise introduction shows you how to build applications with Roo, using the framework's shell as an intelligent and timesaving code-completion tool. It's an ideal RAD tool because Roo does much of the tedious code maintenance.
You'll get started by building a simple customer relationship management application, complete with step-by-step instructions and code examples. Learn how to control any part of the application with Roo's opt-in feature, while using this open source framework to automate the rest of the code.
* Set up a Spring application and working Maven build to see Roo in action
* Address persistence with JPA and the Neo4j graph database—and learn how Roo supports NoSQL databases
* Use Roo’s database reverse-engineering feature to generate a data model from an existing schema
* Build Roo applications with Spring MVC, Spring WebFlow, Google Web Toolkit, Vaadin, and other web frameworks
* Secure and test your application
update, and deletion of the Customer entity that we generated. It happily obliged, filling in all the gaps required to get our plain old Java project converted into a web application, and generating the required Spring MVC controller and supporting web views. The controller is presented below in its entirety: package com.crmco.crm.web; import import import import com.crmco.crm.domain.Customer; org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
you’ve updated the view since it was first generated. The second thing that strikes us is the sheer number of files. The page that contains the form to create clients lives in src/main/webapps/WEB-INF/views/clients/create.jspx. Open the create.jspx and—above all—don’t panic. The few stanzas you see before you really are all the code required to display the page you saw in your browser. You’re standing on the shoulders of giants here, and that should be comforting, but I suspect you want to know
following: @NotNull @DateTimeFormat(style = "S-") private Date birthday; Save the entity and then watch the console; Spring Roo will update all of the existing scaffolding code. You’ll need to also update the database table with the new column. Issue this SQL on the console. alter table customer add column birthday date not null; Redeploy. A new date picker widget will be visible on the form. You can reorder the fields of the form in src/main/webapp/WEB-INF/views/customers/create.jspx. Spring
44 | Chapter 3: From Prototype to Production The http element describes which roles may access which URLs. The access attribute on the intercept-url elements uses Spring Expression Language statements to specify which tests to run when unauthorized access is requested. Questions about the qualifications of a request are delegated to an authentication-manager, which you can see configured below. Like all things
expect. Those shadow definition accessors and mutators we created earlier will still show up in the code completion prompt in your favorite IDE. Additionally, every Spring Roo project ships with a correctly configured Maven build that automatically processes the code at compile time, so everything builds correctly. Getting Started The Tooling Spring Roo is based on the sophisticated interplay between several moving parts. To do its work, Spring Roo needs to play a role during your development,