Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 72 lines (50 sloc) 1.955 kB
feb647a @qmx updating readme
qmx authored
1 # aerogear-controller-demo - very lean mvc controller
2
3 ## how to create a new project
4
5 ### basic use case
6 1. add the maven dependency
7
8 <dependency>
9 <groupId>org.jboss.aerogear</groupId>
10 <artifactId>aerogear-controller</artifactId>
11 <version>1.0.0.Alpha</version>
12 <scope>compile</scope>
13 </dependency>
14
15 1. create a pojo controller
16
17 public class Home {
18 public void index() {
19 }
20 }
21
22 1. create a Java class containing the routes (must extend `AbstractRoutingModule`)
23
24 public class Routes extends AbstractRoutingModule {
25
26 @Override
27 public void configuration() {
28 route()
29 .from("/")
30 .on(RequestMethod.GET)
31 .to(Home.class).index();
32 }
33 }
34
35 1. create a jsp page at `/WEB-INF/pages/<Controller Class Name>/<method>.jsp`
36
37 <!-- /WEB-INF/pages/Home/index.jsp -->
38 <html>
39 <body>
40 <p>hello from index!</p>
41 </body>
42 </html>
43
44 ### parameter population
45
46 You can use immutable beans straight away as controller parameters:
47
48 public class Store {
49 public Car save(Car car) {
50 return car;
51 }
52 }
53
54 This can be populated by putting a route to it (preferrably via post, of course)
55
56 route()
57 .from("/cars")
58 .on(RequestMethod.POST)
59 .to(Store.class).save(param(Car.class));
60
61
62 And you can use a simple html form for it, by just following the convention:
63
64 <input type="text" name="car.color"/>
65 <input type="text" name="car.brand"/>
66
67 The car object will be automatically populated with the provided values - note that it supports deep linking, so this would work fine too:
68
69 <input type="text" name="car.brand.owner"/>
70
71 All the intermediate objects are created automatically.
Something went wrong with that request. Please try again.