- protected void setNoCaching(HttpServletResponse res) {
- //nothing in Mir can or should be cached as it's all dynamic...
- //
- //this needs to be done here and not per page (via meta tags) as some
- //browsers have problems w/ it per-page -mh
- res.setHeader("Pragma", "no-cache");
- res.setDateHeader("Expires", 0);
- res.setHeader("Cache-Control", "no-cache");
- }
-
- /**
- * Bind the language to the session
- */
- protected void setLanguage(HttpSession session, String language) {
- session.setAttribute("Language", language);
- }
-
- protected void setLocale(HttpSession session, Locale loc) {
- session.setAttribute("Locale", loc);
- }
-
- /**
- * Get the session-bound language
- */
- protected String getLanguage(HttpServletRequest req, HttpSession session) {
- String lang = (String) session.getAttribute("Language");
- if (lang == null || lang.equals("")) {
- return getAcceptLanguage(req);
- }
- else {
- return lang;
- }
- }
-
- /**
- * get the locale either from the session or the accept-language header ot the request
- * this supersedes getLanguage for the new i18n
- */
- public Locale getLocale(HttpServletRequest req) {
- Locale loc=null;
- HttpSession session = req.getSession(false);
- if (session!=null) {
- // session can be null in case of logout
- loc = (Locale) session.getAttribute("Locale");
- }
- // if there is nothing in the session get it fron the accept-language
- if (loc == null) {
- loc = req.getLocale();
- }
- return loc;
- }
-
- /**
- * Checks the Accept-Language of the client browser.
- * If this language is available it returns its country-code,
- * else it returns the standard-language
- */
- protected String getAcceptLanguage(HttpServletRequest req) {
- Locale loc = req.getLocale();
- lang = loc.getLanguage();
- return lang;
+ protected void setNoCaching(HttpServletResponse aResponse) {
+ //nothing in Mir can or should be cached as it's all dynamic...
+ //
+ //this needs to be done here and not per page (via meta tags) as some
+ //browsers have problems w/ it per-page -mh
+ aResponse.setHeader("Pragma", "no-cache");
+ aResponse.setDateHeader("Expires", 0);
+ aResponse.setHeader("Cache-Control", "no-cache");
+ }
+
+ /**
+ * Bind the language to the session
+ */
+ protected void setLanguage(HttpSession session, String language) {
+ logger.debug("setting language to " + language);
+
+ session.setAttribute("language", language);
+ session.setAttribute("locale", new Locale(language, ""));
+ }
+
+ /**
+ * Get the session-bound language
+ */
+ protected String getLanguage(HttpServletRequest aRequest, HttpSession session) {
+ String lang = (String) session.getAttribute("language");
+
+ if (lang == null || lang.length()==0) {
+ lang = getAcceptLanguage(aRequest);
+ }
+
+ return lang;
+ }
+
+ /**
+ * get the locale either from the session or the accept-language header ot the request
+ * this supersedes getLanguage for the new i18n
+ */
+ public Locale getLocale(HttpServletRequest aRequest) {
+ Locale loc = null;
+ HttpSession session = aRequest.getSession(false);
+ if (session != null) {
+ // session can be null in case of logout
+ loc = (Locale) session.getAttribute("locale");
+ }
+ // if there is nothing in the session get it fron the accept-language
+ if (loc == null) {
+ loc = aRequest.getLocale();