cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@cocoon.apache.org
Subject [Cocoon Wiki] Updated: JXTemplateGenerator
Date Tue, 06 Jul 2004 09:53:05 GMT
   Date: 2004-07-06T02:53:05
   Editor: LeszekGawron <lgawron@mobilebox.pl>
   Wiki: Cocoon Wiki
   Page: JXTemplateGenerator
   URL: http://wiki.apache.org/cocoon/JXTemplateGenerator

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -207,3 +207,27 @@
   </map:pipeline>
 </map:sitemap>
 }}}
+==== Database interaction ====
+Even though JXTemplateGenerator caches the view data it does not mean the controller will
know about that. If your script contains heavy calculations or database operations this is
what you can do (based on: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108617011419745&w=2)
+
+If your business object takes an age to instantiate, and you can decide 
+whether or not to instantiate it based upon request parameters, then 
+wrap it in a lighter component that does (in pseudocode):
+
+{{{
+lightObject.getValidity() {
+  return request.parameters["a"]+ request.parameters["b"];
+}
+
+lightObject.getHeavyBusinessObject() {
+  if (this.heavyBusinessObject == null) {
+     this.heavyBusinessObject = HeavyBusinessObjectBuilder.newObject();
+  }
+  return this.heavyBusinessObject;
+}
+}}}
+
+Then, in your jxt, you use {{{jx:cache-validity="lightObject.getValidity()"}}} construct,
and then later in 
+your jxt, you access your heavy object with 
+{{{#{/lightObject/HeavyObject/property1} }}}. This latter expression will only 
+be invoked if the page is not cached.

Mime
View raw message