caelum/vraptor-contrib — pull request #33 by marcioferlan (2014-07-03 06:39:46+00:00)
Title: adding vraptor4js-plugin

Hello,

I would like to share with VRaptor 4 developers this plugin I created. It's been quite useful for myself a couple friends of mine as well. It makes it easier to create a JavaScript client to a VRaptor4-powered REST service application.

In summary, it exposes Controller actions (public methods) as methods of a JS object with the same controller name and methods signatures. Imagine you have REST actions in your Controllers like this one:
```
@Controller
public class PersonController {
@Get("/person/details")
public void details(){
final Person person = new Person("Marcio"); // retrieve a person record
result.use(Results.json()).from(person).recursive().serialize();
}
}
```
Now, from within your JS code you can invoke them as easily as this:
```

```
See? You get a JS object with your controller's name with all public methods of it available. You don't have to worry about the underlying Ajax infrastructure involved in binding your JS component to your VRaptor Controller methods. You can freely change the methods URLs, HTTP Methods (GET, POST, etc) as you wish and VRaptor4js does the trick for you automatically using either AngularJS (default) or jQuery (that's configurable).

I hope the community will enjoy it and contribute with the project to improve it. Comments are welcome!

Thanks in advance!

Marcio Lima
marcioferlan@gmail.com