public ModelAndView userEdit(final HttpServletRequest request, final Model model, @ModelAttribute(ModelConstants.USER_FORM) UserForm userForm) throws Exception {
ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), BoUrls.USER_EDIT.getVelocityPage());
final RequestData requestData = requestUtil.getRequestData(request);
final String userCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_USER_CODE);
final User user = userService.getUserByCode(userCode);
UserViewBean userViewBean = backofficeViewBeanFactory.buildViewBeanUser(requestData, user);
if(userViewBean == null){
final String url = requestUtil.getLastRequestUrl(request);
return new ModelAndView(new RedirectView(url));
}
model.addAttribute(ModelConstants.URL_BACK, backofficeUrlService.generateUrl(BoUrls.USER_DETAILS, requestData, user));
request.setAttribute(ModelConstants.USER_VIEW_BEAN, userViewBean);
Object[] params = {user.getLastname() + " " + user.getFirstname() + " (" + user.getLogin() + ")"};
overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, BoUrls.USER_DETAILS.getKey(), params);
return modelAndView;
}