Grzegorz Kossakowski pisze: > Hugh Sparks pisze: >> This is a 2.1 to 2.2 migration issue. >> >> I created a simple c2 block using: >> >> mvn archetype:create \ >> -DarchetypeGroupId=org.apache.cocoon \ >> -DarchetypeArtifactId=cocoon-22-archetype-block \ >> -DarchetypeVersion=1.0.0-RC3-SNAPSHOT \ >> -DgroupId=csparks.com \ >> -DartifactId=AAQuotes >> >> Then I modified it to do an example I have working in >> cocoon 2.1: a simple application that displays a >> randomly selected quotation and image. >> >> The quotations work as expected, but the path to the >> images in the result.jx template (shown below) requires >> the name of my block in the path: >> >> <img src="AAQuotes/${imageNumber}.gif"/> >> >> I ported this example from a working cocoon 2.1.X version >> and the image tag was simply: >> >> <img src="${imageNumber}.gif"/> >> >> Why is the block name required in the path to fetch the image >> when using cocoon 2.2? I would expect the location of the sitemap >> to be the root for finding files. If I omit the block name, I >> get an error of the form: >> >> javax.servlet.ServletException: No block for /148.gif > > I wonder why request for "/148.gif" ever happens. I mean, isn't a browser > supposed to make request > relatively to the path of html document? If so, the mount path of a block > should not be making any > problems at all. > > Another comment is that making a block simply mounted at "/" AND basing on > this setting when > developing a block is not a good idea for two reasons: > 1. Mount path of block can be changed externally (to the block) by using > Cocoon Spring Configurator > and suitable property > 2. The idea of block is that it is reusable unit that has it's own URI space > for living. This design > decision makes it possible to extend and compose blocks.
Oups, hit the "send" button too early. I wanted to say, that if you need an absolute path of resource in a block you should use "servlet: protocol + servletLinkRewriter" combo. Forms block makes an extensive use of this technique and you can have a look at this document[1] to get an idea how it works. I would only add that if you need to reference a resource from current (your own) block you can use this syntax: servlet:/path/to/your/resource (ommitting the part that contains block's name) [1] http://cocoon.apache.org/2.2/blocks/forms/1.0/1351_1_1.html -- Grzegorz Kossakowski Committer and PMC Member of Apache Cocoon http://reflectingonthevicissitudes.wordpress.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]