You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kjetil Kjernsmo <Kj...@computas.com> on 2008/07/31 17:41:29 UTC

Rewriting EncodeURLTransformer to encode the locale parameter

Hi all,

I've been struggling a few days with adding a locale parameter to the local 
URLs in pages I serve. It should be really simple, just add the parameter to 
all hrefs that points to a resource within the site. I've tried to do it with 
XSLT through various approaches, but all unsuccessful, it is either very 
fragile string matching, too fragile to be useful, or too complicated, in 
that it breaks my architecture. 

However, I see that the EncodeURLTransformer is doing almost the same thing. 
It add a session-id parameter if it is doesn't exist, mine should add a 
locale parameter if it doesn't exist. 

EncodeURLTransformer are 400 lines of code though, some of which I don't 
understand, so I'm hesitant to hack based on it. For one thing, I don't 
understand if it restricts the URL rewriting to URLs that point to resources 
on the same site, and if so, how it does it.

So, I was wondering if someone has time to hold my hand while doing this? 
Also, this might be useful for the Cocoon project, as I think it is really 
important for LocaleAction to be useful, it's request feature is really quite 
useless without such a transformer. 

Please?


Kind regards 

Kjetil Kjernsmo
-- 
Senior Knowledge Engineer
Direct: +47 6783 1136 | Mobile: +47 986 48 234
Email: kjetil.kjernsmo@computas.com   
Web: http://www.computas.com/

|  SHARE YOUR KNOWLEDGE  |

Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | 
Fax:+47 6783 1001


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


When are servlet connections required?

Posted by Hugh Sparks <hu...@csparks.com>.
I'm confused about when servlet connections need to be
specified and when the servlet:/ protocol must be used.

For example, I have a demo webapp that depends on one block, 'myBlock'.
When I run the webapp, the content from myBlock is displayed by this browser url:

    http://localhost:8888/myBlock

For this to work, it isn't necessary to specify a servlet connection
in the webapp's SitemapServlet bean.

But if the webapp uses forms, it is necessary to specify these connections:

<servlet:connections>
    <entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/>
    <entry key="forms" value-ref="org.apache.cocoon.forms.impl.servlet"/>
    <entry key="style-default" value-ref="org.apache.cocoon.samples.style.default.servlet"/>
</servlet:connections>

I'm sure I have a misconception about how these entry keys are used.
Could someone explain when and why these expressions are required
to reach a block? (And sometimes why not.)

Thanks,

-Hugh Sparks


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Rewriting EncodeURLTransformer to encode the locale parameter

Posted by Kjetil Kjernsmo <Kj...@computas.com>.
On Thursday 31 July 2008 20:11:10 Robin Wyles wrote:
> Maybe you could use the LinkRewriterTransformer [1] to achieve this  
> along with your own custom InputModule to add the locale parameter.

Oh, OK. Actually, I looked at that but realised that I didn't quite understand 
what it did, I thought it more did something like mod_rewrite, i.e. rewrite 
incoming URLs.

> That said, the LinkRewriterTransformer looks up the InputModule based  
> on the url scheme, so you would have to use a custom scheme (e.g.  
> locale:) for all the 'schemeless' (e.g. "/path/to/some/page.html")  
> links you wanted rewritten.

Hmmmm, OK. I'll look into it, but I think I found an XSLT way that sort of 
works too.

Kind regards 

Kjetil Kjernsmo
-- 
Senior Knowledge Engineer
Direct: +47 6783 1136 | Mobile: +47 986 48 234
Email: kjetil.kjernsmo@computas.com   
Web: http://www.computas.com/

|  SHARE YOUR KNOWLEDGE  |

Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47 6783 1000 | 
Fax:+47 6783 1001


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Rewriting EncodeURLTransformer to encode the locale parameter

Posted by Robin Wyles <ro...@robinwyles.com>.
Hi Kjetil,

Maybe you could use the LinkRewriterTransformer [1] to achieve this  
along with your own custom InputModule to add the locale parameter.

That said, the LinkRewriterTransformer looks up the InputModule based  
on the url scheme, so you would have to use a custom scheme (e.g.  
locale:) for all the 'schemeless' (e.g. "/path/to/some/page.html")  
links you wanted rewritten.

Robin

1. http://cocoon.apache.org/2.2/blocks/linkrewriter/1.0/1102_1_1.html



On 31 Jul 2008, at 16:41, Kjetil Kjernsmo wrote:

> Hi all,
>
> I've been struggling a few days with adding a locale parameter to  
> the local
> URLs in pages I serve. It should be really simple, just add the  
> parameter to
> all hrefs that points to a resource within the site. I've tried to  
> do it with
> XSLT through various approaches, but all unsuccessful, it is either  
> very
> fragile string matching, too fragile to be useful, or too  
> complicated, in
> that it breaks my architecture.
>
> However, I see that the EncodeURLTransformer is doing almost the  
> same thing.
> It add a session-id parameter if it is doesn't exist, mine should  
> add a
> locale parameter if it doesn't exist.
>
> EncodeURLTransformer are 400 lines of code though, some of which I  
> don't
> understand, so I'm hesitant to hack based on it. For one thing, I  
> don't
> understand if it restricts the URL rewriting to URLs that point to  
> resources
> on the same site, and if so, how it does it.
>
> So, I was wondering if someone has time to hold my hand while doing  
> this?
> Also, this might be useful for the Cocoon project, as I think it is  
> really
> important for LocaleAction to be useful, it's request feature is  
> really quite
> useless without such a transformer.
>
> Please?
>
>
> Kind regards
>
> Kjetil Kjernsmo
> -- 
> Senior Knowledge Engineer
> Direct: +47 6783 1136 | Mobile: +47 986 48 234
> Email: kjetil.kjernsmo@computas.com
> Web: http://www.computas.com/
>
> |  SHARE YOUR KNOWLEDGE  |
>
> Computas AS  Vollsveien 9, PO Box 482, N-1327 Lysaker | Phone:+47  
> 6783 1000 |
> Fax:+47 6783 1001
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>