Struts Notes
It is annoying to have to set up two action mappings to have one do validation and the other not do validation, for the first time the user requests a resource. Example
to preserve MVC I want to go to Login.do which uses login.jsp as the view. Then I want to submit this form to Login.do and have it validate the LoginForm bean and call business logic. Two solutions create two action mappings Login.do ( no validation, just an ActionForward to login.jsp ) and LoginSubmit.do ( validation usual struts flow ).
The alternative is to have just the one Login.do mapping and in teh LoginAction execute method, check to see if this is the user's first time, and if so return mapping.getInputForward immediately. The conditional could check to see if this is a GET or check to see if all parameters where null. I think a smarter Struts would do the second by default.
It is annoying to have to set up two action mappings to have one do validation and the other not do validation, for the first time the user requests a resource. Example
to preserve MVC I want to go to Login.do which uses login.jsp as the view. Then I want to submit this form to Login.do and have it validate the LoginForm bean and call business logic. Two solutions create two action mappings Login.do ( no validation, just an ActionForward to login.jsp ) and LoginSubmit.do ( validation usual struts flow ).
The alternative is to have just the one Login.do mapping and in teh LoginAction execute method, check to see if this is the user's first time, and if so return mapping.getInputForward immediately. The conditional could check to see if this is a GET or check to see if all parameters where null. I think a smarter Struts would do the second by default.

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home