Author: jleroux
Date: Thu Nov 5 17:38:42 2009 New Revision: 833096 URL: http://svn.apache.org/viewvc?rev=833096&view=rev Log: A slightly modified patch from Patrick Antivackis "A way to generate no cache header for the views" (https://issues.apache.org/jira/browse/OFBIZ-3091) - OFBIZ-3091 Patrick : The goal of this improvement is to allow at the view level, through setup in the controller.xml file, to generate no-cache http headers. Example is included for the showcart view of the ecommerce application. JLR : I have commented out Patrick's example in controller and put a comment about its usage Modified: ofbiz/trunk/framework/webapp/dtd/site-conf.xsd ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Modified: ofbiz/trunk/framework/webapp/dtd/site-conf.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/dtd/site-conf.xsd?rev=833096&r1=833095&r2=833096&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/dtd/site-conf.xsd (original) +++ ofbiz/trunk/framework/webapp/dtd/site-conf.xsd Thu Nov 5 17:38:42 2009 @@ -338,5 +338,16 @@ <xs:attribute type="xs:string" name="info"/> <xs:attribute type="xs:string" name="content-type"/> <xs:attribute type="xs:string" name="encoding"/> + <xs:attribute name="no-cache" default="false"> + <xs:annotation> + <xs:documentation>Send no-cache headers if set to true.</xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> </xs:attributeGroup> </xs:schema> Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java?rev=833096&r1=833095&r2=833096&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java Thu Nov 5 17:38:42 2009 @@ -471,6 +471,7 @@ public String contentType; public String encoding; public String description; + public boolean noCache = false; public ViewMap(Element viewMapElement) { this.name = viewMapElement.getAttribute("name"); @@ -478,6 +479,7 @@ this.type = viewMapElement.getAttribute("type"); this.info = viewMapElement.getAttribute("info"); this.contentType = viewMapElement.getAttribute("content-type"); + this.noCache = "true".equals(viewMapElement.getAttribute("no-cache")); this.encoding = viewMapElement.getAttribute("encoding"); this.description = UtilXml.childElementValue(viewMapElement, "description"); if (UtilValidate.isEmpty(this.page)) { Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=833096&r1=833095&r2=833096&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Thu Nov 5 17:38:42 2009 @@ -819,6 +819,12 @@ if (Debug.verboseOn()) Debug.logVerbose("The ContentType for the " + view + " view is: " + contentType, module); + boolean viewNoCache = viewMap.noCache; + if (viewNoCache) { + UtilHttp.setResponseBrowserProxyNoCache(resp); + if (Debug.verboseOn()) Debug.logVerbose("Sending no-cache headers for view [" + nextPage + "]", module); + } + try { if (Debug.verboseOn()) Debug.logVerbose("Rendering view [" + nextPage + "] of type [" + viewMap.type + "]", module); ViewHandler vh = viewFactory.getViewHandler(viewMap.type); Modified: ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=833096&r1=833095&r2=833096&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Thu Nov 5 17:38:42 2009 @@ -1900,6 +1900,7 @@ <!-- Cart Views --> <view-map name="editShoppingList" type="screen" page="component://ecommerce/widget/ShoppingListScreens.xml#editShoppingList"/> <view-map name="showcart" type="screen" page="component://ecommerce/widget/CartScreens.xml#showcart"/> + <!--view-map name="showcart" type="screen" page="component://ecommerce/widget/CartScreens.xml#showcart" no-cache="true"/--><!-- to be used to avoid "conflicts" when someone use the same machine with different user logins --> <view-map name="showAllPromotions" type="screen" page="component://ecommerce/widget/CartScreens.xml#showAllPromotions"/> <view-map name="showPromotionDetails" type="screen" page="component://ecommerce/widget/CartScreens.xml#showPromotionDetails"/> |
Free forum by Nabble | Edit this page |