Il 07/11/2011 12:48, Andre Juffer ha scritto:
On 11/07/2011 01:43 PM, Francesco Chicchiriccò wrote:
On 07/11/2011 12:35, Andre Juffer wrote:

What happens if you use one of standard generators - like the XML
generator in the first example? I mean:

<map:match pattern="create/image/creator/*">
<map:generate src="sax-pipeline/{map:1}.xml" />

You should now get an exception for something missing: is it
"sax-pipeline/3276800.xml" or "sax-pipeline/null.xml"?


This is exactly the error I get. I tried:

<map:generate src="{map:1}.xml" />

The exception I get

Caused by: java.io.FileNotFoundException: /home/juffer/TriBC/projects/cocoon3-webapp/tribc-img/src/main/resources/COB-INF/3276800.xml (No such file or directory)

Ok, this means that {map:1} is handled correctly by the sitemap, since it is passed to XML generator.

See attached a patch for cocoon-sample that modifies the current sample for StringTemplateGenerator by passing an additional parameter from URL match: once applied the patch and launched "mvn jetty:run" under cocoon-sample, you will be able to access URLs like as

http://localhost:8888/string-template/generator/anUrlParameter

getting an XML document that shows, among usual things, "anUrlParameter" or whatever value you pass after generator/.

I am giving this example because StringTemplateGenerator is the first generator coming into my mind that supports parameter passing.

I suspect there should be something wrong with your generator, then; take a look at StringTemplateGenerator's sources [1] for reference.

Cheers.

[1] http://svn.apache.org/repos/asf/cocoon/cocoon3/trunk/cocoon-stringtemplate/src/main/java/org/apache/cocoon/stringtemplate/StringTemplateGenerator.java

--
Francesco Chicchiriccò

Apache Cocoon Committer and PMC Member
http://people.apache.org/~ilgrosso/

Index: cocoon-sample/src/main/resources/COB-INF/string-template/template.xml
===================================================================
--- cocoon-sample/src/main/resources/COB-INF/string-template/template.xml	(revisione 1198636)
+++ cocoon-sample/src/main/resources/COB-INF/string-template/template.xml	(copia locale)
@@ -23,6 +23,7 @@
   </head>
   <body>
     <h3>StringTemplate demo</h3>
+    <p>urlparameter=$urlparameter$</p>
     <p>parameter=$parameter$</p>
 $if(booleanParameter)$
 <p>booleanParameter was TRUE</p>
Index: cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
===================================================================
--- cocoon-sample/src/main/resources/COB-INF/sitemap.xmap	(revisione 1198636)
+++ cocoon-sample/src/main/resources/COB-INF/sitemap.xmap	(copia locale)
@@ -549,8 +549,9 @@
 
     <!-- StringTemplate -->
     <map:pipeline type="noncaching">
-      <map:match wildcard="string-template/generator">
+      <map:match wildcard="string-template/generator/*">
         <map:generate type="string-template" src="string-template/template.xml">
+	  <map:parameter name="urlparameter" value="{map:1}"/>
 	  <map:parameter name="parameter" value="A value"/>
 	  <map:parameter name="booleanParameter" value="{jexl:true}"/>
         </map:generate>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to