You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Michael Ralston <mi...@ralston.id.au> on 2006/05/08 03:59:50 UTC

Changing content generator

I've been working on an EJB content repository for a while now, and I'm having 
some trouble understanding a fairly fundamental concept.

How do I set up my content generator in the cocoon xmap so lenya sources 
content via my generator?

I've made a class which extends ServiceableGenerator and I've modelled its 
behaviour around the LenyaMetaDataGenerator. It gets the publication, area, 
documentId and language from the session and then fetches the appropriate 
content via the NodeBean I've created.

I think this might actually work, but what should I be putting into the 
sitemap.xmap to make it use this class for content generation? I've read the 
cocoon generator tutorial 
http://cocoon.apache.org/2.1/tutorial/tutorial-generator.html and I have a 
basic understanding of how generators work and how to define them in the 
xmap, just wanted to know what to match in the pipeline to get the content 
passed through to my class.

In the jcrsource/sitemap.xmap I've found the following snippets of xml which 
seems to be doing what I need, but I don't really understand how they work. 
Why is this matching 'lenya-repository-content.xml'? How can that make all 
content requests go through to the jcr generator? I know I'm missing 
something really obvious, can somebody please point it out? :)

Michael

-- from jcrsource/sitemap.xmap
    <map:pipeline>
      <map:match pattern="lenya-repository-content.xml">
        <map:select type="parameter">
          <map:parameter name="parameter-selector-test" 
value="{request-param:scope}"/>
          <map:when test="repository">
            <map:generate type="jcr-sys-view">
              <map:parameter name="root" value="/lenya"/>
            </map:generate>
          </map:when>
          <map:otherwise>
            <map:generate type="jcr-sys-view">
              <map:parameter name="root" 
value="/lenya/pubs/{page-envelope:publication-id}"/>
            </map:generate>
          </map:otherwise>
        </map:select>
        <map:serialize type="xml"/>
      </map:match>

    </map:pipeline>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Changing content generator

Posted by Thorsten Scherler <th...@apache.org>.
El lun, 08-05-2006 a las 11:59 +1000, Michael Ralston escribió:
> I've been working on an EJB content repository for a while now, and I'm having 
> some trouble understanding a fairly fundamental concept.
> 
> How do I set up my content generator in the cocoon xmap so lenya sources 
> content via my generator?
> 
> I've made a class which extends ServiceableGenerator and I've modelled its 
> behaviour around the LenyaMetaDataGenerator. It gets the publication, area, 
> documentId and language from the session and then fetches the appropriate 
> content via the NodeBean I've created.
> 

ok, I will pick it up later on again.

> I think this might actually work, but what should I be putting into the 
> sitemap.xmap to make it use this class for content generation? I've read the 
> cocoon generator tutorial 
> http://cocoon.apache.org/2.1/tutorial/tutorial-generator.html and I have a 
> basic understanding of how generators work and how to define them in the 
> xmap, just wanted to know what to match in the pipeline to get the content 
> passed through to my class.

You need to define the 
<map:generator name="ejb" src="org.apache.lenya.EJBGenerator"/> in the
component section.

Then you need to add a match like
   <map:match pattern="ejb.xml">
      <map:generate type="ejb"/>
      <map:serialize type="xml"/>
   </map:match>

> 
> In the jcrsource/sitemap.xmap I've found the following snippets of xml which 
> seems to be doing what I need, but I don't really understand how they work. 
> Why is this matching 'lenya-repository-content.xml'? How can that make all 
> content requests go through to the jcr generator? I know I'm missing 
> something really obvious, can somebody please point it out? :)


http://cocoon.apache.org/2.1/tutorial/tutorial-generator.html#New
+Concepts

The answer is lying in the parameter.
          <map:generate type="requestExample">
		<parameter name="param1" value="{visibleName1}"/>
		<parameter name="param2" value="{visibleName2}"/>
	  </map:generate>

The normal situation would be to pass parameter to the generator. You
wrote: "It gets the publication, area, 
> documentId and language from the session and then fetches the appropriate 
> content via the NodeBean I've created."

That can be easy be done with parameter of the sitemap. 

          <map:generate type="ejb">
		<parameter name="publication-id" value="{page-envelope:publication-id}"/>
		<parameter name="doc-id" value="{page-envelope:doc-id}"/>
	  </map:generate>

Makes sense?

salu2

> 
> Michael
> 
> -- from jcrsource/sitemap.xmap
>     <map:pipeline>
>       <map:match pattern="lenya-repository-content.xml">
>         <map:select type="parameter">
>           <map:parameter name="parameter-selector-test" 
> value="{request-param:scope}"/>
>           <map:when test="repository">
>             <map:generate type="jcr-sys-view">
>               <map:parameter name="root" value="/lenya"/>
>             </map:generate>
>           </map:when>
>           <map:otherwise>
>             <map:generate type="jcr-sys-view">
>               <map:parameter name="root" 
> value="/lenya/pubs/{page-envelope:publication-id}"/>
>             </map:generate>
>           </map:otherwise>
>         </map:select>
>         <map:serialize type="xml"/>
>       </map:match>
> 
>     </map:pipeline>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
> 
-- 
thorsten

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org