From cocoon-dev-return-20311-apmail-xml-cocoon-dev-archive=xml.apache.org@xml.apache.org Fri Dec 21 20:54:06 2001 Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 96742 invoked by uid 500); 21 Dec 2001 20:54:05 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 96731 invoked from network); 21 Dec 2001 20:54:05 -0000 Date: Fri, 21 Dec 2001 13:49:18 -0700 (Mountain Standard Time) From: Michael McKibben To: Subject: RE: How do I add objects to the objectModel Map In-Reply-To: <18F49733FEE5D5119A590000F8FE9A94937F65@mbtlipnt01.btlabs.bt.co.uk> Message-ID: X-X-Sender: mmckibben@moab.ncube.com MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N The action approach is the easiest way to add custom objects to the cocoon object model (at least that I know of, perhaps there is a better way?) I don't think that this adds any significant overhead to the request since actions are thread safe and can be pooled (now if your action has to do a lot of work to create the business object-- e.g. calling a database-- then this could add to the overall response time.) Regards, --mike On Fri, 21 Dec 2001 david.greaves@idl-bt.com wrote: > Thanks - I've been discussing this on the user list too. > > what I want to do is instantiate myBusinessObject and place it into the > objectModel so I can do exactly that (except you do it in the pipeline not > the section unless I'm mistaken :) > > Why? > I would like to create an object that provides metadata about the site > structure that can be accessed by various Velocity or JSP (or whatever) > components. This (these) may also provide interfaces to other business > logic. > > The sensible place seems to be the objectModel. > > David Rosenstrauch suggested I use actions to populate the Map. > This seems good and we now have a custom action that simply adds a component > to the map where Velocity can be confgigured to look for it. > > However, this requires we stick an action in every ; I'm still > looking for a place to ensure that the objectModel is updated for *every* > request. > > One approach that may work is to have a pattern that matches every request > and simply calls an action that modifies the objectModel and returns null. > But that sounds like it could be inefficient. > > David > > > > -----Original Message----- > > From: Michael McKibben [mailto:mmckibben@ncube.com] > > Sent: 21 December 2001 18:28 > > To: cocoon-dev > > Subject: Re: How do I add objects to the objectModel Map > > > > > > > > This feature is for exporting objects already in the Cocoon object map > > to > > the Velocity template context. So they must already exist. > > But let's say > > you knew that, then in your sitemap, here is how you would make some > > object named "myBusinessObject" in the cocoon object map available to > > your > > velocity template as "$myBusinessObject": > > > > (in your sitemap.xmap) > > > > ... > > > src="org.apache.cocoon.generation.VelocityGenerator" pool-max="32" > > pool-min="16" pool-grow="4"> > > > > > > ... > > > > > > Hope this helps! > > > > --mike > > > > On Tue, 18 Dec 2001 david.greaves@idl-bt.com wrote: > > > > > Hi > > > > > > I hope this is straightforward... > > > > > > How do I add objects to the objectModel Map? > > > > > > > > http://xml.apache.org/cocoon/userdocs/generators/velocity-gene > rator.html > > says: > > > (optional; > > 0..n) - Export the object specified by key from the Cocoon object map > to the > > Velocity context of the template. The object can be accessed from the > > template as name. Be careful to use a valid VTL variable name. > > > > I've looked through the code but can't figure this one out. > > > > David > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org > > For additional commands, email: cocoon-dev-help@xml.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org > For additional commands, email: cocoon-dev-help@xml.apache.org > > --------------------------------------------------------------------- > To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org > For additional commands, email: cocoon-dev-help@xml.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org