cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McKibben <mmckib...@ncube.com>
Subject RE: How do I add objects to the objectModel Map
Date Fri, 21 Dec 2001 20:49:18 GMT
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 <generators> 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 <match>; 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)
> > <generators default="file">
> >  ...
> >  <generator name="velocity"
> > src="org.apache.cocoon.generation.VelocityGenerator" pool-max="32"
> > pool-min="16" pool-grow="4">
> >    <export-object key="myBusinessObject" name="myBusinessObject"/>
> >  </generator>
> >  ...
> >  </generators>
> >
> > 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:
> > <export-object key="objectMapKey" name="velocityContextName"/>
> (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


Mime
View raw message