|
Modified: ofbiz/branches/webhelp-2012-12-07/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl
URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/common/webcommon/includes/ServerHour24HourFormatJs.ftl Sat Jan 19 10:26:15 2013 @@ -20,15 +20,19 @@ under the License. jQuery(document).ready(function() { window.setInterval(function(){clock()}, 1000); var serverTimestamp = 0; - var date + var date; function clock() { if (jQuery("#${clockField}").text() === "${uiLabelMap.CommonServerHour}:") { - serverTimestamp = getServerTimestamp("getServerTimestampAsLong"); - date = new Date(serverTimestamp); + serverTimestamp = getServiceResult("getServerTimestampAsLong")['serverTimestamp']; + serverTimeZone = getServiceResult("getServerTimeZone")['serverTimeZone'];; + initTimeZone(); + date = new timezoneJS.Date(serverTimestamp, serverTimeZone); } else { date.setSeconds(date.getSeconds() + 1); } - jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + dateFormat(date, "yyyy-mm-dd HH:MM:ss")); + // dateFormat does not respect the timezone :/ Fortunately toString is what we want :) + //jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + dateFormat(date, "yyyy-mm-dd HH:MM:ss")); + jQuery("#${clockField}").text("${uiLabelMap.CommonServerHour}: " + date.toString()); } }) </script> \ No newline at end of file Modified: ofbiz/branches/webhelp-2012-12-07/framework/common/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/common/widget/CommonScreens.xml?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/common/widget/CommonScreens.xml (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/common/widget/CommonScreens.xml Sat Jan 19 10:26:15 2013 @@ -154,9 +154,10 @@ under the License. <!-- jQuery CSSs --> <set field="layoutSettings.styleSheets[+0]" value="/images/jquery/plugins/asmselect/jquery.asmselect-1.0.4a-beta.css" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/selectall.js" global="true" /> - <set field="layoutSettings.javaScripts[]" value="/images/date.format-1.2.3-min.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/fieldlookup.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/GooglemapMarkers.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/date/date.format-1.2.3-min.js" global="true" /> + <set field="layoutSettings.javaScripts[]" value="/images/date/date.timezone-min.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/miscAjaxFunctions.js" global="true" /> <set field="layoutSettings.javaScripts[]" value="/images/selectMultipleRelatedValues.js" global="true" /> <set field="visualThemeId" from-field="userPreferences.VISUAL_THEME" global="true" /> Modified: ofbiz/branches/webhelp-2012-12-07/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Sat Jan 19 10:26:15 2013 @@ -18,11 +18,23 @@ *******************************************************************************/ package org.ofbiz.entity.connection; +import java.sql.Connection; +import java.sql.Driver; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import javax.transaction.TransactionManager; + +import javolution.util.FastMap; + import org.apache.commons.dbcp.ConnectionFactory; import org.apache.commons.dbcp.DriverConnectionFactory; import org.apache.commons.dbcp.PoolableConnectionFactory; import org.apache.commons.dbcp.managed.LocalXAConnectionFactory; import org.apache.commons.dbcp.managed.ManagedDataSource; +import org.apache.commons.dbcp.managed.PoolableManagedConnectionFactory; import org.apache.commons.dbcp.managed.XAConnectionFactory; import org.apache.commons.pool.impl.GenericObjectPool; import org.ofbiz.base.util.Debug; @@ -32,16 +44,6 @@ import org.ofbiz.entity.datasource.Gener import org.ofbiz.entity.transaction.TransactionFactory; import org.w3c.dom.Element; -import javax.transaction.TransactionManager; -import java.sql.Connection; -import java.sql.Driver; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import javolution.util.FastMap; - /** * DBCPConnectionFactory */ @@ -146,7 +148,7 @@ public class DBCPConnectionFactory imple // create the pool object factory - PoolableConnectionFactory factory = new PoolableConnectionFactory(xacf, pool, null, null, true, true); + PoolableConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, pool, null, null, true, true); factory.setValidationQuery("select 1 from entity_key_store where key_name = ''"); factory.setDefaultReadOnly(false); Modified: ofbiz/branches/webhelp-2012-12-07/framework/images/webapp/images/miscAjaxFunctions.js URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/images/webapp/images/miscAjaxFunctions.js?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/images/webapp/images/miscAjaxFunctions.js (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/images/webapp/images/miscAjaxFunctions.js Sat Jan 19 10:26:15 2013 @@ -144,7 +144,37 @@ function checkUomConversion(request, par return data['exist']; } -function getServerTimestamp(request){ - data = getServiceResult(request); - return data['serverTimestamp']; +/* initTimeZone is used to intialise the path to timezones files + +The timezone region that loads on initialization is North America (the Olson 'northamerica' file). +To change that to another reqion, set timezoneJS.timezone.defaultZoneFile to your desired region, like so: + timezoneJS.timezone.zoneFileBasePath = '/tz'; + timezoneJS.timezone.defaultZoneFile = 'asia'; + timezoneJS.timezone.init(); + +If you want to preload multiple regions, set it to an array, like this: + + timezoneJS.timezone.zoneFileBasePath = '/tz'; + timezoneJS.timezone.defaultZoneFile = ['asia', 'backward', 'northamerica', 'southamerica']; + timezoneJS.timezone.init(); + +By default the timezoneJS.Date timezone code lazy-loads the timezone data files, pulling them down and parsing them only as needed. + +For example, if you go with the out-of-the-box setup, you'll have all the North American timezones pre-loaded -- +but if you were to add a date with a timezone of 'Asia/Seoul,' it would grab the 'asia' Olson file and parse it +before calculating the timezone offset for that date. + +You can change this behavior by changing the value of timezoneJS.timezone.loadingScheme. The three possible values are: + + timezoneJS.timezone.loadingSchemes.PRELOAD_ALL -- this will preload all the timezone data files for all reqions up front. This setting would only make sense if you know your users will be using timezones from all around the world, and you prefer taking the up-front load time to the small on-the-fly lag from lazy loading. + timezoneJS.timezone.loadingSchemes.LAZY_LOAD -- the default. Loads some amount of data up front, then lazy-loads any other needed timezone data as needed. + timezoneJS.timezone.loadingSchemes.MANUAL_LOAD -- Preloads no data, and does no lazy loading. Use this setting if you're loading pre-parsed JSON timezone data. + + More at https://github.com/mde/timezone-js + +*/ +function initTimeZone() { + timezoneJS.timezone.zoneFileBasePath = '/images/date/timezones/min'; + timezoneJS.timezone.loadingSchemes.PRELOAD_ALL; + timezoneJS.timezone.init(); } \ No newline at end of file Modified: ofbiz/branches/webhelp-2012-12-07/framework/webapp/config/requestHandler.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/webapp/config/requestHandler.properties?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/webapp/config/requestHandler.properties (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/webapp/config/requestHandler.properties Sat Jan 19 10:26:15 2013 @@ -1,2 +1,5 @@ -# -- N if you want to use external requests (not in available in current controller), see OFBIZ-5037 +# -- N if you want to use external requests, see OFBIZ-5037 throwRequestHandlerExceptionOnMissingLocalRequest=Y + +# -- Default HTTP status-code, see OFBIZ-5109 +status-code=302 Modified: ofbiz/branches/webhelp-2012-12-07/framework/webapp/dtd/site-conf.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/webapp/dtd/site-conf.xsd?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/webapp/dtd/site-conf.xsd (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/webapp/dtd/site-conf.xsd Sat Jan 19 10:26:15 2013 @@ -25,6 +25,7 @@ under the License. <xs:element minOccurs="0" ref="description"/> <xs:element minOccurs="0" ref="owner"/> <xs:element minOccurs="0" ref="errorpage"/> + <xs:element minOccurs="0" ref="status-code"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="handler"/> <xs:element minOccurs="0" ref="protect"/> <xs:element minOccurs="0" ref="firstvisit"/> @@ -58,6 +59,7 @@ under the License. <xs:element name="description" type="xs:string"/> <xs:element name="owner" type="xs:string"/> <xs:element name="errorpage" type="xs:string"/> + <xs:element name="status-code" type="xs:string"/> <xs:element name="handler"> <xs:annotation> <xs:documentation> @@ -639,6 +641,18 @@ under the License. </xs:restriction> </xs:simpleType> </xs:attribute> + <xs:attribute name="status-code" type="xs:string"> + <xs:annotation> + <xs:documentation> + A redirection HTTP status-code + If set it will override (cascading) the default status-code sets in requestHandler.properties + and the possible status-code sets at the controller level (inclusive included controllers) + + Most possible redirection status-codes are 301, 303 and 307. + 302 (the Java default) is not recommended for SEO reasons. + </xs:documentation> + </xs:annotation> + </xs:attribute> </xs:attributeGroup> <xs:element name="redirect-parameter"> <xs:annotation> Modified: ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java Sat Jan 19 10:26:15 2013 @@ -82,6 +82,7 @@ public class ConfigXMLReader { private String owner; private String securityClass; private String defaultRequest; + private String statusCode; private List<URL> includes = FastList.newInstance(); private Map<String, Event> firstVisitEventList = FastMap.newInstance(); @@ -145,6 +146,20 @@ public class ConfigXMLReader { return null; } + public String getStatusCode() { + if (statusCode != null) { + return statusCode; + } + for (URL includeLocation: includes) { + ControllerConfig controllerConfig = getControllerConfig(includeLocation); + String statusCode = controllerConfig.getStatusCode(); + if (statusCode != null) { + return statusCode; + } + } + return null; + } + public String getOwner() { if (owner != null) { return owner; @@ -297,6 +312,7 @@ public class ConfigXMLReader { } this.errorpage = UtilXml.childElementValue(rootElement, "errorpage"); + this.statusCode = UtilXml.childElementValue(rootElement, "status-code"); Element protectElement = UtilXml.firstChildElement(rootElement, "protect"); if (protectElement != null) { this.protectView = protectElement.getAttribute("view"); @@ -593,6 +609,7 @@ public class ConfigXMLReader { public String name; public String type; public String value; + public String statusCode; public boolean saveLastView = false; public boolean saveCurrentView = false; public boolean saveHomeView = false; @@ -603,6 +620,7 @@ public class ConfigXMLReader { this.name = responseElement.getAttribute("name"); this.type = responseElement.getAttribute("type"); this.value = responseElement.getAttribute("value"); + this.statusCode = responseElement.getAttribute("status-code"); this.saveLastView = "true".equals(responseElement.getAttribute("save-last-view")); this.saveCurrentView = "true".equals(responseElement.getAttribute("save-current-view")); this.saveHomeView = "true".equals(responseElement.getAttribute("save-home-view")); Modified: ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Sat Jan 19 10:26:15 2013 @@ -20,7 +20,6 @@ package org.ofbiz.webapp.control; import static org.ofbiz.base.util.UtilGenerics.checkMap; -import java.io.IOException; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URL; @@ -66,9 +65,9 @@ import org.owasp.esapi.errors.EncodingEx public class RequestHandler { public static final String module = RequestHandler.class.getName(); - private static final Boolean THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST = - UtilProperties.propertyValueEqualsIgnoreCase("requestHandler.properties", "throwRequestHandlerExceptionOnMissingLocalRequest", "Y"); - + private boolean throwRequestHandlerExceptionOnMissingLocalRequest = UtilProperties.propertyValueEqualsIgnoreCase( + "requestHandler.properties", "throwRequestHandlerExceptionOnMissingLocalRequest", "Y"); + private String statusCodeString = UtilProperties.getPropertyValue("requestHandler.properties", "status-code", "302"); public static RequestHandler getRequestHandler(ServletContext servletContext) { RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); if (rh == null) { @@ -115,6 +114,9 @@ public class RequestHandler { // get the controllerConfig once for this method so we don't have to get it over and over inside the method ConfigXMLReader.ControllerConfig controllerConfig = this.getControllerConfig(); Map<String, ConfigXMLReader.RequestMap> requestMapMap = controllerConfig.getRequestMapMap(); + String controllerStatusCodeString = controllerConfig.getStatusCode(); + if(UtilValidate.isNotEmpty(controllerStatusCodeString != null)) + statusCodeString = controllerStatusCodeString; // workaround if we are in the root webapp String cname = UtilHttp.getApplicationName(request); @@ -155,10 +157,10 @@ public class RequestHandler { } } - // if no matching request is found in the controller, depending on THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST + // if no matching request is found in the controller, depending on throwRequestHandlerExceptionOnMissingLocalRequest // we throw a RequestHandlerException or RequestHandlerExceptionAllowExternalRequests if (requestMap == null) { - if (THROW_REQUEST_HANDLER_EXCEPTION_ON_MISSING_LOCAL_REQUEST) throw new RequestHandlerException(requestMissingErrorMessage); + if (throwRequestHandlerExceptionOnMissingLocalRequest) throw new RequestHandlerException(requestMissingErrorMessage); else throw new RequestHandlerExceptionAllowExternalRequests(); } @@ -245,7 +247,7 @@ public class RequestHandler { String newUrl = RequestHandler.makeUrl(request, response, urlBuf.toString()); if (newUrl.toUpperCase().startsWith("HTTPS")) { // if we are supposed to be secure, redirect secure. - callRedirect(newUrl, response, request); + callRedirect(newUrl, response, request, statusCodeString); return; } } @@ -260,7 +262,7 @@ public class RequestHandler { } String newUrl = RequestHandler.makeUrl(request, response, urlBuf.toString(), true, false, false); if (newUrl.toUpperCase().startsWith("HTTP")) { - callRedirect(newUrl, response, request); + callRedirect(newUrl, response, request, statusCodeString); return; } } @@ -507,7 +509,8 @@ public class RequestHandler { if (UtilValidate.isNotEmpty(queryString)) { redirectTarget += "?" + queryString; } - callRedirect(makeLink(request, response, redirectTarget), response, request); + + callRedirect(makeLink(request, response, redirectTarget), response, request, statusCodeString); // the old/uglier way: doRequest(request, response, previousRequest, userLogin, delegator); @@ -569,20 +572,25 @@ public class RequestHandler { } } + String responseStatusCode = nextRequestResponse.statusCode; + if(UtilValidate.isNotEmpty(responseStatusCode)) + statusCodeString = responseStatusCode; + + if ("url".equals(nextRequestResponse.type)) { if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is a URL redirect." + " sessionId=" + UtilHttp.getSessionId(request), module); - callRedirect(nextRequestResponse.value, response, request); + callRedirect(nextRequestResponse.value, response, request, statusCodeString); } else if ("cross-redirect".equals(nextRequestResponse.type)) { // check for a cross-application redirect if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is a Cross-Application redirect." + " sessionId=" + UtilHttp.getSessionId(request), module); String url = nextRequestResponse.value.startsWith("/") ? nextRequestResponse.value : "/" + nextRequestResponse.value; - callRedirect(url + this.makeQueryString(request, nextRequestResponse), response, request); + callRedirect(url + this.makeQueryString(request, nextRequestResponse), response, request, statusCodeString); } else if ("request-redirect".equals(nextRequestResponse.type)) { if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is a Request redirect." + " sessionId=" + UtilHttp.getSessionId(request), module); - callRedirect(makeLinkWithQueryString(request, response, "/" + nextRequestResponse.value, nextRequestResponse), response, request); + callRedirect(makeLinkWithQueryString(request, response, "/" + nextRequestResponse.value, nextRequestResponse), response, request, statusCodeString); } else if ("request-redirect-noparam".equals(nextRequestResponse.type)) { if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is a Request redirect with no parameters." + " sessionId=" + UtilHttp.getSessionId(request), module); - callRedirect(makeLink(request, response, nextRequestResponse.value), response, request); + callRedirect(makeLink(request, response, nextRequestResponse.value), response, request, statusCodeString); } else if ("view".equals(nextRequestResponse.type)) { if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is a view." + " sessionId=" + UtilHttp.getSessionId(request), module); @@ -681,6 +689,13 @@ public class RequestHandler { return "/error/error.jsp"; } + /** Returns the default status-code for this request. */ + public String getStatusCode(HttpServletRequest request) { + String statusCode = getControllerConfig().getStatusCode(); + if (UtilValidate.isNotEmpty(statusCode)) return statusCode; + return null; + } + /** Returns the ServletContext Object. */ public ServletContext getServletContext() { return context; @@ -728,11 +743,17 @@ public class RequestHandler { return nextPage; } - private void callRedirect(String url, HttpServletResponse resp, HttpServletRequest req) throws RequestHandlerException { + private void callRedirect(String url, HttpServletResponse resp, HttpServletRequest req, String statusCodeString) throws RequestHandlerException { if (Debug.infoOn()) Debug.logInfo("Sending redirect to: [" + url + "], sessionId=" + UtilHttp.getSessionId(req), module); // set the attributes in the session so we can access it. Enumeration<String> attributeNameEnum = UtilGenerics.cast(req.getAttributeNames()); Map<String, Object> reqAttrMap = FastMap.newInstance(); + Integer statusCode; + try { + statusCode = Integer.valueOf(statusCodeString); + } catch (NumberFormatException e) { + statusCode = 303; + } while (attributeNameEnum.hasMoreElements()) { String name = attributeNameEnum.nextElement(); Object obj = req.getAttribute(name); @@ -749,10 +770,10 @@ public class RequestHandler { } // send the redirect - try { - resp.sendRedirect(url); - } catch (IOException ioe) { - throw new RequestHandlerException(ioe.getMessage(), ioe); + try { + resp.setStatus(statusCode); + resp.setHeader("Location", url); + resp.setHeader("Connection", "close"); } catch (IllegalStateException ise) { throw new RequestHandlerException(ise.getMessage(), ise); } Modified: ofbiz/branches/webhelp-2012-12-07/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java URL: http://svn.apache.org/viewvc/ofbiz/branches/webhelp-2012-12-07/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=1435518&r1=1435517&r2=1435518&view=diff ============================================================================== --- ofbiz/branches/webhelp-2012-12-07/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original) +++ ofbiz/branches/webhelp-2012-12-07/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Sat Jan 19 10:26:15 2013 @@ -415,7 +415,12 @@ public abstract class ModelScreenWidget } public String getTitle(Map<String, Object> context) { - return this.titleExdr.expandString(context); + String title = this.titleExdr.expandString(context); + StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); + if (simpleEncoder != null) { + title = simpleEncoder.encode(title); + } + return title; } public Menu getNavigationMenu() { @@ -1549,7 +1554,12 @@ public abstract class ModelScreenWidget } public String getAlt(Map<String, Object> context) { - return this.alt.expandString(context); + String alt = this.alt.expandString(context); + StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); + if (simpleEncoder != null) { + alt = simpleEncoder.encode(alt); + } + return alt; } public String getUrlMode() { |
| Free forum by Nabble | Edit this page |
