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
<parameter/> tags.
* @return boolean Signals successfull test.
*/
boolean select (String expression, Map objectModel, Parameters
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 RecursiveDirectoryTraversalAction.java 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:
...
<components>
...
<actions default="RecursiveDirectoryTraversalAction">
<action name="RecursiveDirectoryTraversalAction"
src="org.apache.forrest.plugin.internal.view.acting.RecursiveDirectoryTraversalAction"/>
</actions>
...
</components>
<locator>
<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}" />
</act>
<location
src="{defaults:view-themes}/{defaults:theme}{defaults:theme-ext}"
/>
</match>
</locator>
...
I needed do change some classes to allow actions in the lm to be
matched:
? java/org/apache/forrest/locationmap/lm/ActNode.java
M java/org/apache/forrest/locationmap/lm/MatchNode.java
M java/org/apache/forrest/locationmap/lm/SelectNode.java
M java/org/apache/forrest/locationmap/lm/LocationMap.java
M java/org/apache/forrest/locationmap/lm/LocatorNode.java
The step where I need some help with in ActNode.java 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);
...
}
working.
Where can I get the redirector, resolver and the source that I need to
parse to the action? Any tips welcome.
TIA
salu2
--
thorsten
"Together we stand, divided we fall!"
Hey you (Pink Floyd)