• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

How to do server side validation in Spring with MultiActionController ?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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*
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic