Author: jonesde
Date: Wed Jul 4 01:20:55 2007 New Revision: 553122 URL: http://svn.apache.org/viewvc?view=rev&rev=553122 Log: Appled patch from Adrian Crum in Jira #OFBIZ-1117 to add some timeZone passing and retreival code Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java ofbiz/trunk/framework/common/webcommon/includes/header.ftl ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java?view=diff&rev=553122&r1=553121&r2=553122 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilHttp.java Wed Jul 4 01:20:55 2007 @@ -43,6 +43,7 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; +import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -537,6 +538,29 @@ if (UtilValidate.isNotEmpty(localeString) && session.getAttribute("locale") == null) { UtilHttp.setLocale(session, UtilMisc.parseLocale(localeString)); } + } + + public static void setTimeZone(HttpServletRequest request, String tzId) { + UtilHttp.setTimeZone(request.getSession(), UtilDateTime.toTimeZone(tzId)); + } + + public static void setTimeZone(HttpSession session, TimeZone timeZone) { + session.setAttribute("timeZone", timeZone); + } + + public static TimeZone getTimeZone(HttpServletRequest request) { + HttpSession session = request.getSession(); + TimeZone timeZone = (TimeZone) session.getAttribute("timeZone"); + if (timeZone == null) { + String tzId = null; + Map userLogin = (Map) session.getAttribute("userLogin"); + if (userLogin != null) { + tzId = (String) userLogin.get("lastTimeZone"); + } + timeZone = UtilDateTime.toTimeZone(tzId); + session.setAttribute("timeZone", timeZone); + } + return timeZone; } /** Modified: ofbiz/trunk/framework/common/webcommon/includes/header.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/includes/header.ftl?view=diff&rev=553122&r1=553121&r2=553122 ============================================================================== --- ofbiz/trunk/framework/common/webcommon/includes/header.ftl (original) +++ ofbiz/trunk/framework/common/webcommon/includes/header.ftl Wed Jul 4 01:20:55 2007 @@ -68,9 +68,7 @@ ${uiLabelMap.CommonWelcome}! </#if> </p> - <#assign nowStamp = Static["org.ofbiz.base.util.UtilDateTime"].nowTimestamp()> - <#assign timeZone = Static["org.ofbiz.base.util.UtilDateTime"].toTimeZone((userLogin.lastTimeZone)?default(""))> - <p>${Static["org.ofbiz.base.util.UtilDateTime"].timeStampToString(nowStamp, timeZone, locale)}</p> + <p>${Static["org.ofbiz.base.util.UtilDateTime"].timeStampToString(nowTimestamp, timeZone, locale)}</p> <form method="post" action="<@ofbizUrl>setSessionLocale</@ofbizUrl>"> <select name="locale"> <option value="${locale.toString()}">${locale.getDisplayName(locale)}</option> Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?view=diff&rev=553122&r1=553121&r2=553122 ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Wed Jul 4 01:20:55 2007 @@ -27,6 +27,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.TimeZone; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -101,6 +102,7 @@ // some needed info for when running the service Locale locale = UtilHttp.getLocale(request); + TimeZone timeZone = UtilHttp.getTimeZone(request); HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); @@ -226,6 +228,8 @@ if ("userLogin".equals(name)) continue; // don't include locale, that is also taken care of below if ("locale".equals(name)) continue; + // don't include timeZone, that is also taken care of below + if ("timeZone".equals(name)) continue; Object value = null; if (modelParam.stringMapPrefix != null && modelParam.stringMapPrefix.length() > 0) { @@ -305,6 +309,11 @@ // include the Locale object if (locale != null) { serviceContext.put("locale", locale); + } + + // include the TimeZone object + if (timeZone != null) { + serviceContext.put("timeZone", timeZone); } // invoke the service Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?view=diff&rev=553122&r1=553121&r2=553122 ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Wed Jul 4 01:20:55 2007 @@ -25,6 +25,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.TimeZone; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -171,6 +172,9 @@ // some things also seem to require this, so here it is: request.setAttribute("userLogin", userLogin); + // set up the user's time zone + context.put("timeZone", UtilHttp.getTimeZone(request)); + // ========== setup values that are specific to OFBiz webapps context.put("request", request); |
Free forum by Nabble | Edit this page |