Package it.hotel.controller.locale

Source Code of it.hotel.controller.locale.SetLocaleController

/*
Copyright (C) European Community 2008 - Licensed under the EUPL V.1.0 (http://ec.europa.eu/idabc/en/document/6523)
*/
package it.hotel.controller.locale;

import java.util.Locale;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.util.StringUtils;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
import org.springframework.web.servlet.support.RequestContextUtils;



/**
*
*
*/
public class SetLocaleController extends AbstractController {
 
  protected LocaleContainer localeContainer;
 
 
  public LocaleContainer getLocaleContainer() {
    return localeContainer;
  }


  public void setLocaleContainer(LocaleContainer localeContainer) {
    this.localeContainer = localeContainer;
  }

    /**
     * @throws
     * @return
     */
  @Override
  protected ModelAndView handleRequestInternal(HttpServletRequest req,
            HttpServletResponse res) throws Exception {
    String language = req.getParameter("language");
    Locale locale = StringUtils.parseLocaleString(language);
    LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(req);
    localeResolver.setLocale(req, res, locale);
    localeContainer.setLocale(locale.getLanguage());
    return new ModelAndView("redirect:/");
  }
}
TOP

Related Classes of it.hotel.controller.locale.SetLocaleController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.