This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to do server side validation in Spring with MultiActionController ?

 
purvang joshi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*Hello Friends.*
*Can anybody suggest me how to do serverside validation in spring while extemding controller with multiActionController*
*I am trying to do this with below code but its not working*

*public class LoginController extends MultiActionController {*
* *
* public LoginController()*
* {*
* setMethodNameResolver(new InternalPathMethodNameResolver());*
* setValidators(new Validator[] { new Validator() {*
* public boolean supports(Class clazz) {*
* return clazz.isAssignableFrom(LoginDetailDTO.class);*
* }*

* public void validate(Object command, Errors errors) {*
* ValidationUtils.rejectIfEmpty(errors, "userId", "", "Age is required");*
* ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "",*
* "Name is required");*
* }*

* *
* } });*

* }*

* HttpSession session;*
* *
* public ModelAndView login(HttpServletRequest request,*
* HttpServletResponse response)*
* throws Exception*
* {*
* *
* *
* return new ModelAndView("home");*
* }*
* *
* public ModelAndView validateUser(HttpServletRequest request,*
* HttpServletResponse response,LoginDetailDTO command)*
* throws Exception*
* {*
* *
* *
* String fileName="";*
* String message="";*
* LoginDetailDTO d=(LoginDetailDTO)command;*
* *
* LoginDetailDTO loginDetailDTO=new LoginDetailDTO();*
* loginDetailDTO.setUserId(request.getParameter("userId"));*
* loginDetailDTO.setPassword(request.getParameter("password"));*
* *
* LoginDetailDTO user = getLoginServie().authenticateUser(loginDetailDTO);*
* *
* session=request.getSession();*
* ModelAndView mv=new ModelAndView();*
* mv.addObject("bindObj", request);*
* if(null != user)*
* {*
* session.setAttribute("user",user);*
* if(null != user.getFirstTimeLogin() && user.getFirstTimeLogin().equalsIgnoreCase("Y")){*
* *
* fileName = "password";*
* }else{*
* fileName="main";*
* }*
* }else{*
* //user name or password incorrect*
* fileName="home";*
* message="Incorrect User ID or Password";*
* }*
* *
* *
* return new ModelAndView(fileName,"message",message);*
* *
* }*
* *
* *
* *
* *
* *
* *
*}*


*Please help me on this*
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic