I am trying to figure out Vraptor's validation. From what I can see, there is no usage of it in JForum3 to date.
As an example, I am trying to validate the Login screen (
http://localhost:8080/jforum3/user/login.page). Currently, if you leave the fields blank and hit "login" it will throw an exception since the UserActions.authenticateUser() method is blowing up on the call to validateLogin() with a null pointer exception.
I added the following method to the UserActions class in order to trigger the Vraptor validation:
The validation method is triggered automatically by Vraptor as it should. If the validation passes (username != null) then everything is fine, it forwards on to the authenticateUser method as it should.
If the validation method fails (username == null) is where I'm running into problems. Leaving things as they are right now, the following exception is generated:
Feb 9, 2009 2:27:34 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for
servlet jforum threw exception
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:312)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at net.jforum.core.support.vraptor.DefaultViewManager.directForward(DefaultViewManager.java:85)
at net.jforum.core.support.vraptor.DefaultViewManager.forward(DefaultViewManager.java:60)
at org.vraptor.interceptor.ViewInterceptor.intercept(ViewInterceptor.java:36)
at org.vraptor.core.VRaptorExecution.execute(VRaptorExecution.java:98)
at org.vraptor.core.DefaultController.execute(DefaultController.java:46)
at org.vraptor.VRaptorServlet.service(VRaptorServlet.java:74)
at net.jforum.JForumServlet.service(JForumServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at net.jforum.core.support.hibernate.OpenSessionInViewFilter.doFilter(OpenSessionInViewFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
I tried following the directions in Vraptor about adding a file called "views.properties" and putting a handler for the invalid in it. In this case I tried the following:
user.login.invalid = /login.jsp
but the result is the same.
Unfortunately I'm a bit confused since Jforum3 does not use the standard Vraptor URL
pattern.
Can anybody tell me where I am going wrong here? Or, has the JFroum3 custom URL pattern broken the Vraptor validation capability (hence it is not used)?
Can anybody on the dev team tell me how you expect to handle simple form validations in Jforum3, if not with the Vraptor validation?
Thanks.
[originally posted on jforum.net by Zinger]