You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Rice Yeh <ri...@gmail.com> on 2006/11/16 08:00:16 UTC

How to run the cocoon-blocks-fw-sample block?

Hi,
 In studying the document
http://wiki.apache.org/cocoon-data/attachments/GT2006Notes/attachments/12-CocoonBlocks.pdf,
I like to have a real feeling of it. So I try  the cocoon-blocks-fw-sample
block, but got no good luck. Can anyone give me some information on doing
this?

Rice

Re: How to run the cocoon-blocks-fw-sample block?

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
Rice Yeh skrev:
> Hi,
>  In studying the document 
> http://wiki.apache.org/cocoon-data/attachments/GT2006Notes/attachments/12-CocoonBlocks.pdf 
> <http://wiki.apache.org/cocoon-data/attachments/GT2006Notes/attachments/12-CocoonBlocks.pdf>, 
> I like to have a real feeling of it. So I try  the 
> cocoon-blocks-fw-sample block, but got no good luck. Can anyone give 
> me some information on doing this?
One way is to build the trunk an point your webcontainer to 
cocoon-dist-samples. It contains all the blocks, including the blocks fw 
samples. I haven't tested this approach for a while, so I don't know how 
well it works.

Otherwise you can extend the cocoon-webapp pom with a dependency on the 
blocks fw sample:

    <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-blocks-fw-sample</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </dependency>

and rebuild the cocoon-webapp and start jetty:

  $ mvn package
  $ mvn jetty:run

then you point your browser to

  http://localhost:8888/blocks-test/cocoon-blocks-fw-sample1/test

and the other examples in the block fw samples. The URI above is handled 
by some different parts of the system. The servlet context:

  /blocks-test

is handled by the DispatcherServlet and configured in the web.xml 
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-webapp/src/main/webapp/WEB-INF/web.xml. 
Then the block servlets are Spring managed components that are 
configured in the blocks, 
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-sample/src/main/resources/META-INF/cocoon/spring/cocoon-blocks-fw-sample-blockServlet1.xml, 
etc. Each block servlet definition defines a mount path e.g.

  /cocoon-blocks-fw-sample1

Then at last the servlet that is embedded in the the block servlet (e.g. 
the sitemap servlet) gets the remaining part of the uri as path info:

  /test

Which will be handled by the sitemap in the directory that the block 
context url points to (using the blockcontext source that I descriobided 
in a mail a few days ago), 
http://svn.apache.org/repos/asf/cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-sample/src/main/resources/COB-INF/test1/sitemap.xmap.

HTH

/Daniel