cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: Block resources in 2.2 (Forms in particular case)
Date Thu, 25 Jan 2007 22:57:52 GMT
Grzegorz Kossakowski skrev:
> Hello,
> 
> I've tried Forms blocks using /core/cocoon-webapp block(?) lately and
> I've found that resources loading does not work.

Are you using it the "standard" way: 
http://localhost:8888/blocks/cocoon-forms-sample/ or are you using it 
through the blocks-fw? In the former case resource loading seems to work 
for me.

> I would like to fix it
> but in the manner of using blocks-fw as it seems to be mature enough. It
> is, right?

It should be stable enough, although I'm working on changing the naming 
as discussed in http://marc.theaimsgroup.com/?t=116731854200001&r=1&w=2. 
But that will only change some names for the user, so it will be easy to 
adapt any work that you start to the new naming.

> So my questions are:
> 1. Should block resources be served directly by block owning them? I
> mean, should request for some javascript files be dispatched (by
> blocks-fw dispatcher) directly to forms block and some matcher in there
> would catch up the request?

In most cases this should be the best solution.

> 2. Or maybe always block that uses forms block should catch the request
> for resources and redirect them (by using some source from block-fw?) to
> the forms block?

This requires more work and means less separation of concern as the 
using block must know and repeat the resource handling of the used block.

But in cases where you want the used block to be "internal only", (i.e. 
not mounted on any path and just usable through the block protocol or 
named dispacther), alternative 2. is the best option.

> 3. What about paths? Are they supposed to be absolute?

It makes the the using block slightly less reusable, as it assumes that 
the used block is mounted at specific position. But for a normal 
application that not is supposed to be reused in other, unknown, 
applications, it is OK to use absolute paths for resources (relative to 
the context though).

> If not, which
> block (and phase of processing request) is responsible for link
> rewriting and what technique is advised?

You can use the block-path module together with the 
LinkRewriterTransformer in the linkrewriter block. A setup like:

   <map:transformer
     name="linkrewriter"
     src="org.apache.cocoon.transformation.LinkRewriterTransformer">
       <link-attrs>href src</link-attrs>
       <schemes>block</schemes>
   </map:transformer>

have worked before, but I haven't tested for a while.

It would simplify use to have a special purpose transformer or maybe 
even a servlet filter, that took care about the rewriting.

> Thanks for any pointers, advices. I would like to say, that I'm going to
> document all these sort of things when I was confident enough myself.

Great.

What I wrote above is my preliminary thoughts. More use is needed before 
we can have any more authoritative best practice.

It would be interesting to hear about the thoughts from other people who 
  are using the blocks-fw.

/Daniel

Mime
View raw message