public ModelAndView customerDetails(final HttpServletRequest request, final Model model) throws Exception {
ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), BoUrls.CUSTOMER_DETAILS.getVelocityPage());
final RequestData requestData = requestUtil.getRequestData(request);
final String customerCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CUSTOMER_CODE);
final Customer customer = customerService.getCustomerByCode(customerCode);
if(customer != null){
modelAndView.addObject(ModelConstants.CUSTOMER_VIEW_BEAN, backofficeViewBeanFactory.buildViewBeanCustomer(requestUtil.getRequestData(request), customer));
} else {
final String url = requestUtil.getLastRequestUrl(request);
return new ModelAndView(new RedirectView(url));
}
modelAndView.addObject(ModelConstants.CUSTOMER_VIEW_BEAN, backofficeViewBeanFactory.buildViewBeanCustomer(requestData, customer));
model.addAttribute(ModelConstants.URL_BACK, backofficeUrlService.generateUrl(BoUrls.CUSTOMER_LIST, requestData));
Object[] params = {customer.getLastname() + " " + customer.getFirstname()};
overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, BoUrls.CUSTOMER_DETAILS.getKey(), params);
return modelAndView;
}