Take a look at the following logic. It is a web method which can be invoked without any extra configuration or xml!
@Component public class PersonLogic { public void add(Person person) { System.out.println("Adding " + person.getName() + " to the database!"); // invoke dao.save, which can be injected through the constructor } }
When calling the url domain.com/webapp/person.add.logic" it will instantiate the PersonLogic and invoke the add method passing a new Person with its values populated from the request parameters (an input type=text named "person.name", for example, would be used as a parameter to invoker setName in this instatiated person). After that you will be dispatched to person/add.ok.jsp.
No XML file (only the servlet config in web.xml), only one annotation (in this case) and the class is pretty testable and web independent.
Lots of configurations can be done here, we have used all the default.
VRaptor 2.4 comes with many improvements ( see the release notes). There is a new maven plugin which automatically generates the vraptor.xml file. Now, vraptor projects based on maven2 can use mvn jetty:run.
Check also the new ScopeType.FLASH. Objects in that scope will exist until the next request.
It is a web mvc and ioc framework which was based on many frameworks and ideas (JBoss Seam, Stripes, Webwork, Hibernate Annotations etc).
VRaptor2 makes full use of Java 5 Annotations. The result? A simpler way to deal with web programming. Your business logic classes have no contact with javax.servlet API, and there is less need of configuration than with other web controllers.
It favors Convention over Configuration. Why? Because configuration in xml/properties/annotations is always boring, easy to make mistakes and repetitive.
This framework uses a more pragmatic approach, instead of having lots of xml files to configure lifecycle, ioc and other properties. Most of the settings go inside plain Java objects (POJO), so the team knows exactly what is going on, and where.
Take a look at our live demo.
If you need an easy to use controller and your team needs to start producing some handsome code today, VRaptor is a good starting point.
You will find it easy to use and solve many common problems found in Struts/Webwork/other frameworks alike:
Prefer libraries which are not attached to any kind of controller instead of those who aims at giving you everything you desire...
It is known that there is no silver bullet, don't try to use something that claims to be the one, VRaptor is not one, it simply solves some problems that other frameworks left behind or created when they tried to solve everything at the same time.