You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Patrick Refondini <pa...@pobox.com> on 2006/12/18 14:00:13 UTC

Cocoon 2.2 - Use a block for the "root" sitemap

As of my tests a block configured to handle "root" sitemap does only 
strictly answer to / resource call. The rest of its context seems to be 
inaccessible.

Thus, for instance, if a block testblock1 is configured to handle "root" 
sitemap and should serve:
a welcome page at /
some content at /contact.html
some resources at /images/**

only the welcome page at / from this block testblock1 will be accessible 
(with all references to resources,... failing).

Looking at the org.apache.cocoon.blocks.DispatcherServlet source, this 
behaviour is due to the way the service() method chooses which block 
(Servlet) to dispatch to:

Added>>>>
// HARDCODED for root sitemap could be made configurable !?
private static final String DEFAULT_SERVLET = "/";
<<<<Added

protected void service(HttpServletRequest req, HttpServletResponse res) 
throws ServletException, IOException {

(...)

     while (servlet == null && index != -1) {
         path = path.substring(0, index);
         servlet = (Servlet)this.mountableServlets.get(path);
         index = path.lastIndexOf('/');
     }

Added>>>>
     // If no servlet were found try to delegate call to DEFAULT_SERVLET
     if (servlet == null) {
         servlet = (Servlet)this.mountableServlets.get(DEFAULT_SERVLET);
     }
<<<<Added

     if (servlet == null) {
         throw new ServletException("No block for " + req.getPathInfo());
     }

(...)

}


WDYT ? Any caveheat I overlook ?

Patrick


Re: Cocoon 2.2 - Use a block for the "root" sitemap

Posted by Patrick Refondini <pa...@pobox.com>.
Reinhard Poetz wrote:
> Reinhard Poetz wrote:
>> Patrick Refondini wrote:
>>> Daniel Fagerstrom wrote:
>>>> The root servlet should be mounted at "" not "/". Alexander had the 
>>>> same problem. So even if I find the current behavior intuitive, no 
>>>> one else seem to agree ;). So we should probably have special 
>>>> handling of "/" as you suggest.
>>> I just tested "" configuration and it does exactly what I was looking 
>>> for, uh ! Although having special handling of "/", if found 
>>> acceptable in term of coding, could be valuable for dummy users like 
>>> I :O) or those who won't read the docs.
>>> Talking about documentation, would this:
>>> http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1291.html
>>> be the place where the block protocol and configurations like these 
>>> could be best described ?
>>
>> The block documentation should go to 
>> http://cocoon.zones.apache.org/daisy/cdocs-core/g5/1266.html or to one 
>> of its siblings in the menu tree.
> 
> The document that you refered to should contain a short recipie how to 
> add another block to an existing block and continues where "Your first 
> Cocoon application" 
> (http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1159.html) and 
> "Your first Cocoon pipeline" 
> (http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1290.html) end.
> 
Thank you for clarifications. I need more block usage knowledge before 
pretending to produce any useful documentation, but this comes together 
with understanding the existing documentation structure.

Best Regards,

Patrick


Re: Cocoon 2.2 - Use a block for the "root" sitemap

Posted by Reinhard Poetz <re...@apache.org>.
Reinhard Poetz wrote:
> Patrick Refondini wrote:
>> Daniel Fagerstrom wrote:
>>> The root servlet should be mounted at "" not "/". Alexander had the 
>>> same problem. So even if I find the current behavior intuitive, no 
>>> one else seem to agree ;). So we should probably have special 
>>> handling of "/" as you suggest.
>> I just tested "" configuration and it does exactly what I was looking 
>> for, uh ! Although having special handling of "/", if found acceptable 
>> in term of coding, could be valuable for dummy users like I :O) or 
>> those who won't read the docs.
>> Talking about documentation, would this:
>> http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1291.html
>> be the place where the block protocol and configurations like these 
>> could be best described ?
> 
> The block documentation should go to 
> http://cocoon.zones.apache.org/daisy/cdocs-core/g5/1266.html or to one 
> of its siblings in the menu tree.

The document that you refered to should contain a short recipie how to add 
another block to an existing block and continues where "Your first Cocoon 
application" (http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1159.html) 
and "Your first Cocoon pipeline" 
(http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1290.html) end.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Re: Cocoon 2.2 - Use a block for the "root" sitemap

Posted by Reinhard Poetz <re...@apache.org>.
Patrick Refondini wrote:
> Daniel Fagerstrom wrote:
>> The root servlet should be mounted at "" not "/". Alexander had the 
>> same problem. So even if I find the current behavior intuitive, no one 
>> else seem to agree ;). So we should probably have special handling of 
>> "/" as you suggest.
> I just tested "" configuration and it does exactly what I was looking 
> for, uh ! Although having special handling of "/", if found acceptable 
> in term of coding, could be valuable for dummy users like I :O) or those 
> who won't read the docs.
> Talking about documentation, would this:
> http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1291.html
> be the place where the block protocol and configurations like these 
> could be best described ?

The block documentation should go to 
http://cocoon.zones.apache.org/daisy/cdocs-core/g5/1266.html or to one of its 
siblings in the menu tree.

-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------



	
		
___________________________________________________________ 
Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de

Re: Cocoon 2.2 - Use a block for the "root" sitemap

Posted by Patrick Refondini <pa...@pobox.com>.
Daniel Fagerstrom wrote:
> The root servlet should be mounted at "" not "/". Alexander had the same 
> problem. So even if I find the current behavior intuitive, no one else 
> seem to agree ;). So we should probably have special handling of "/" as 
> you suggest.
I just tested "" configuration and it does exactly what I was looking 
for, uh ! Although having special handling of "/", if found acceptable 
in term of coding, could be valuable for dummy users like I :O) or those 
who won't read the docs.
Talking about documentation, would this:
http://cocoon.zones.apache.org/daisy/cdocs-site-main/g2/1291.html
be the place where the block protocol and configurations like these 
could be best described ?

Patrick

> 
> /Daniel
> 
> Patrick Refondini skrev:
>> As of my tests a block configured to handle "root" sitemap does only 
>> strictly answer to / resource call. The rest of its context seems to 
>> be inaccessible.
>>
>> Thus, for instance, if a block testblock1 is configured to handle 
>> "root" sitemap and should serve:
>> a welcome page at /
>> some content at /contact.html
>> some resources at /images/**
>>
>> only the welcome page at / from this block testblock1 will be 
>> accessible (with all references to resources,... failing).
>>
>> Looking at the org.apache.cocoon.blocks.DispatcherServlet source, this 
>> behaviour is due to the way the service() method chooses which block 
>> (Servlet) to dispatch to:
>>
>> Added>>>>
>> // HARDCODED for root sitemap could be made configurable !?
>> private static final String DEFAULT_SERVLET = "/";
>> <<<<Added
>>
>> protected void service(HttpServletRequest req, HttpServletResponse 
>> res) throws ServletException, IOException {
>>
>> (...)
>>
>>     while (servlet == null && index != -1) {
>>         path = path.substring(0, index);
>>         servlet = (Servlet)this.mountableServlets.get(path);
>>         index = path.lastIndexOf('/');
>>     }
>>
>> Added>>>>
>>     // If no servlet were found try to delegate call to DEFAULT_SERVLET
>>     if (servlet == null) {
>>         servlet = (Servlet)this.mountableServlets.get(DEFAULT_SERVLET);
>>     }
>> <<<<Added
>>
>>     if (servlet == null) {
>>         throw new ServletException("No block for " + req.getPathInfo());
>>     }
>>
>> (...)
>>
>> }
>>
>>
>> WDYT ? Any caveheat I overlook ?
>>
>> Patrick
>>
> 


Re: Cocoon 2.2 - Use a block for the "root" sitemap

Posted by Daniel Fagerstrom <da...@nada.kth.se>.
The root servlet should be mounted at "" not "/". Alexander had the same 
problem. So even if I find the current behavior intuitive, no one else 
seem to agree ;). So we should probably have special handling of "/" as 
you suggest.

/Daniel

Patrick Refondini skrev:
> As of my tests a block configured to handle "root" sitemap does only 
> strictly answer to / resource call. The rest of its context seems to 
> be inaccessible.
>
> Thus, for instance, if a block testblock1 is configured to handle 
> "root" sitemap and should serve:
> a welcome page at /
> some content at /contact.html
> some resources at /images/**
>
> only the welcome page at / from this block testblock1 will be 
> accessible (with all references to resources,... failing).
>
> Looking at the org.apache.cocoon.blocks.DispatcherServlet source, this 
> behaviour is due to the way the service() method chooses which block 
> (Servlet) to dispatch to:
>
> Added>>>>
> // HARDCODED for root sitemap could be made configurable !?
> private static final String DEFAULT_SERVLET = "/";
> <<<<Added
>
> protected void service(HttpServletRequest req, HttpServletResponse 
> res) throws ServletException, IOException {
>
> (...)
>
>     while (servlet == null && index != -1) {
>         path = path.substring(0, index);
>         servlet = (Servlet)this.mountableServlets.get(path);
>         index = path.lastIndexOf('/');
>     }
>
> Added>>>>
>     // If no servlet were found try to delegate call to DEFAULT_SERVLET
>     if (servlet == null) {
>         servlet = (Servlet)this.mountableServlets.get(DEFAULT_SERVLET);
>     }
> <<<<Added
>
>     if (servlet == null) {
>         throw new ServletException("No block for " + req.getPathInfo());
>     }
>
> (...)
>
> }
>
>
> WDYT ? Any caveheat I overlook ?
>
> Patrick
>