cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TREGAN Fabien <fabien.tre...@airbus.com>
Subject RE: Include external javascript file
Date Wed, 29 May 2002 11:47:38 GMT
Because it's cleaner :)

The thing you must remember is that ANAY request tht start with /cocoon/ is
sent to COCOON.
If in cocoon/myapp/index.html (wich is generated by cocoon), you have a
relative link "myscript.js", the browser will ask the web server for
cocoon/myapp/myscript.js. The server know that all cocoon/** url are handle
by cocoon, so it ask Cocoon (the servlet) for "myapp/myscript.js", because
it doesn't know that "myapp/script.js" must be processed differently from
myapp/index.html.

So what you must do is have a cocoon pipeline that match *.js and send (via
a reader) the .js file. Since you want it to be clean, you put all the .js's
in a myapp/js directory.

Now you understood, you can do the same for *.gif, *.bmp, *.doc, ...

Another way to serve .js is to use an URL wich is out of the /cocoon/* path
(ex : use an absolute path to http://myserver/js/toto.js, so cocoon won't be
concerned by the request)

hope it's clearer (i doubt :)

fabien.

>-----Message d'origine-----
>De: Rajeev Singh [mailto:rsingh@zapapp.com]
>Date: mercredi 29 mai 2002 13:38
>À: cocoon-users@xml.apache.org
>Objet: RE: Include external javascript file
>
>
>I have a silly question,
>Why do we put {1}.js in js/{1}.js ?
>
>
>
>-----Original Message-----
>From: Bert Van Kets [mailto:bert@vankets.com] 
>Sent: Wednesday, May 29, 2002 1:49 AM
>To: cocoon-users@xml.apache.org
>Subject: Re: Include external javascript file
>
>You must add a pipeline for every filetype you wish to call in your 
>application.
>
>Put your *.js files in the "js" directory and add the 
>following to your 
>pipelines
>
>       <map:match pattern="*.js">
>         <map:read src="js/{1}.js" mime-type="text/javascript"/>
>       </map:match>
>
>Now you can call any external javascript file directly, but it will be 
>served from the js directory.
>Adjust to your liking.
>Bert
>
>At 12:54 28/05/2002 -0700, you wrote:
>
>>A cocoon newbie question:
>>
>>I am trying to include a javascript function from an external 
>.js file 
>>into my xsl stylesheet.
>>
>>I have the following in the xsl stylesheet:
>>
>><head>
>>...
>><script  src="cold_reverse_script.js" language="javascript" ></script>
>>
>></head>
>>
>>The file cold_reverse_script.js is in the same directory as the xsl 
>>stylesheet & contains javascript code for a single function:
>>
>>--------------------------------------------------------------
>---------
>------------------ 
>>
>>function cold_reverse_search_criteria() {
>>
>>javascript code .....
>>
>>                 }
>>--------------------------------------------------------------
>---------
>----------- 
>>
>>
>>I have this entry in my sitemap:
>><map:match pattern="**.js">
>>     <map:read src="{1}.js" mime-type="text/jscript"/>
>></map:match>
>>
>>(I've also tried "text/javascript").
>>
>>However, this does not work.  I get "error on page" whenever I try to 
>>access the javascript function from the .js file.   When I 
>look at the 
>>source for the HTML page in the browser, it shows 
>>"<script  src="cold_reverse_script.js" language="javascript"
>></script>" 
>>just as I've written it in the xsl file, but does not show the code
>that 
>>is in the .js file.
>>
>>If I put the javascript function code directly into the
><script></script> 
>>tags, it works fine, but I'd like to use the external .js file.
>>
>>Any help would be greatly appreciated.
>>
>>Thanks,
>>
>>Beth Naquin
>>SAGEM MORPHO Inc.
>>1145 Broadway Plaza STE 200
>>Tacoma, WA 98402
>>
>>253-597-8245
>
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
>For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>
>
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
>For additional commands, e-mail: <cocoon-users-help@xml.apache.org>
>

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

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


Mime
View raw message