An open API service indexing awesome lists of open source software.

https://github.com/josedonizetti/aerogear-controller-demo


https://github.com/josedonizetti/aerogear-controller-demo

Last synced: 15 days ago
JSON representation

Awesome Lists containing this project

README

        

# aerogear-controller-demo - very lean mvc controller

## how to create a new project

### basic use case
1. add the maven dependency


org.jboss.aerogear
aerogear-controller
1.0.0.Alpha
compile

1. create a pojo controller

public class Home {
public void index() {
}
}

1. create a Java class containing the routes (must extend `AbstractRoutingModule`)

public class Routes extends AbstractRoutingModule {

@Override
public void configuration() {
route()
.from("/")
.on(RequestMethod.GET)
.to(Home.class).index();
}
}

1. create a jsp page at `/WEB-INF/pages//.jsp`




hello from index!





### parameter population

You can use immutable beans straight away as controller parameters:

public class Store {
public Car save(Car car) {
return car;
}
}

This can be populated by putting a route to it (preferrably via post, of course)

route()
.from("/cars")
.on(RequestMethod.POST)
.to(Store.class).save(param(Car.class));

And you can use a simple html form for it, by just following the convention:


The car object will be automatically populated with the provided values - note that it supports deep linking, so this would work fine too:

All the intermediate objects are created automatically.