Patrick Refondini wrote:
Daniel Fagerstrom wrote:
Patrick Refondini skrev:
...
It seems that block protocol is not available from root webapp
according to:
http://www.nabble.com/Configuring-BlockServlets-via-properties-and-sitemap-reloading-for-blocks-t2450880.html
Or do I miss something ?
That is correct. The block servlets are Spring components that are
wired together in a Spring configuration. The block connections are
put into a property map where a key and a component reference are a
associated. The key is used as block name in the block protocol within
the block.
As the root webapp not is a Spring component, it is not obvious how to
use the mechanism for the block protocol within it. I started to
implement another protocol that would make it possible to call blocks
from the root sitemap using the block servlets component identifier,
but I have not found the time to finish it.
It is also possible to access static resources from a block using the
blockcontext protocol. It is however not the recommended way as a
block is intended to be an isolated unit that only should be accessed
through its "public" API in form of the block protocol. The
blockcontext protocol is more intended for internal use in Cocoon and
for setting up the blockcontext property i the block servlet
configuration.
Ok, I already read "bad practise" for the above (certainly from you) in
some thread, but now it is much clearer why.
One can also use a block for the "root" sitemap in this scenario
everything is a block. For the moment I would say that this is the
recommended way for those testing the blocks fw.
Ok, did it like:
mvn archetype:create \
-DarchetypeGroupId=org.apache.cocoon \
-DarchetypeArtifactId=cocoon-22-archetype-block \
-DarchetypeVersion=1.0.0-M5-SNAPSHOT \
-DgroupId=ch.extentis \
-DartifactId=testroot
Modify:
src/main/resources/META-INF/cocoon/spring/block.xml
From:
<property name="mountPath" value="/testroot" />
To:
<property name="mountPath" value="/" />
Do not forget:
cd testroot
mvn install
cd ..
Then this block is accessible as "root" sitemap while included in a
webapp such as:
mvn archetype:create \
-DarchetypeGroupId=org.apache.cocoon \
-DarchetypeArtifactId=cocoon-22-archetype-webapp \
-DarchetypeVersion=1.0.0-M2-SNAPSHOT \
-DgroupId=ch.extentis \
-DartifactId=testwebapp
Modify pom.xml to add dependencies on testroot
cd testwebapp
mvn package jetty:run
testroot block is then accessible via http://localhost:8888/
Patrick
I will try this together with starting testing inter-block protocol
communications. I will certainly start a Block Protocol thread at that
time :)
Thanks for your valuable input,
Patrick
======
I don't know enough about the block archetype to answer the rest of
your questions.
/Daniel