forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <>
Subject [locationmap] How to activate actions in the locationmap
Date Sat, 27 Aug 2005 20:17:59 GMT
On Fri, 2005-08-26 at 08:41 -0400, Tim Williams wrote:

> > Can a selector in the lm provide a map? Can I use:
> > <traversal>
> >    <location src="{calculatedValue}"/>
> > </traversal>
> >
> > If the <traversal> selector returns null then the child will be ignored,
> > otherwise it will use the {calculatedValue} that have been placed in the
> > returning map of the selector. Is that possible?
> I missed this reply.  If I understand the question, the answer is kind
> of.  All null-returning locations would be ignored except the last one
> which would, not surprisingly, actually return null, meaning your
> example above would also return null.  If this is done in the context
> of a parent selector, then maybe it would get ignored -- I'd have to
> check.
> I'll admit that I didn't fully cook the [new traversal selector] idea
> in my head before my fingers started typing it;)  I think this one
> deserves more study and should be filed as a JIRA issue.

I just looked into 
package org.apache.cocoon.selection;
public interface Selector extends Component {

    String ROLE = Selector.class.getName();
     * Selectors test pattern against some objects in a <code>Map</code>
     * model and signals success with the returned boolean value
     * @param expression  The expression to test.
     * @param objectModel The <code>Map</code> containing object of the
     *                    calling environment which may be used
     *                    to select values to test the expression.
     * @param parameters  The sitemap parameters, as specified by
&lt;parameter/&gt; tags.
     * @return boolean    Signals successfull test.
    boolean select (String expression, Map objectModel, Parameters

What I had in mind is not possible with a selector. That leads us to the
question whether it is possible to use actions in lm. The answer was not
out of the box how I found out. ;-) 

I wrote a new action that only
contains the recursive part of the fallbackResolverAction. I tested it
on the sitemap and that worked just fine.

Now I extend my project lm like this:
 <actions default="RecursiveDirectoryTraversalAction">
  <action name="RecursiveDirectoryTraversalAction"
  <match pattern="views/**">
    <act type="RecursiveDirectoryTraversalAction">
      <parameter value="{1}" name="request"/>
      <parameter value="{project:theme}" name="projectFallback"/>
      <parameter value="{project:theme-ext}" name="projectExtension"/>
      <parameter value="{project:content.xdocs}" name="projectDir"/>
      <location src="{uri}" />

I needed do change some classes to allow actions in the lm to be
?      java/org/apache/forrest/locationmap/lm/
M      java/org/apache/forrest/locationmap/lm/
M      java/org/apache/forrest/locationmap/lm/
M      java/org/apache/forrest/locationmap/lm/
M      java/org/apache/forrest/locationmap/lm/

The step where I need some help with in is how do I get:
public String locate(Map objectModel, InvokeContext context) throws
Exception {
  Parameters parameters = resolveParameters(context,objectModel);
  Map substitutions = m_action.act(redirector, resolver, objectModel,
source, parameters);

Where can I get the redirector, resolver and the source that I need to
parse to the action? Any tips welcome.



"Together we stand, divided we fall!" 
Hey you (Pink Floyd)

View raw message