You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by andyhot <an...@di.uoa.gr> on 2006/11/20 12:23:28 UTC

Re: handling extern-asset Javascript

What's wrong with including

<script type="text/javascript" language="javascript"
src="file://usr/local/lib/local.js"></script>

directly into the tapestry template?



Regarding PageRenderSupport.addExternalScript(), I believe you could call
it from a page or component passing a:  
new ExternalResource("file://usr/local/lib/local.js", getLocale())



NISHIMURA Toshio wrote:
> Hi,
>
> I have a problem handling javascript files. The original HTML is following;
>
> <html>
> <head>
> <script type="text/javascript" language="javascript"
> src="common.js"></script>
> <script type="text/javascript" language="javascript"
> src="file://usr/local/lib/local.js"></script>
> </head>
> ...
>
> '/usr/local/lib/local.js' contains machine depended javascript functions.
> In testing situation, I want to use the mock script instead of this.
> So I want to switch the source path of this script.
>
> I can implement the features of "common.js" with "@Script".
> But how can I implement "local.js"?
>
> I can't use "<include-script
> resource-path="file://usr/local/lib/local.js"/>"
> Because the 'resource-path' specifies the class path.
>
> "PageRenderSupport.addExternalScript()" may solve this problem, but I'm
> not sure how to use it.
>   

> Any help would be appreciated.
>
> Toshio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


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


Re: handling extern-asset Javascript

Posted by 西村 俊夫 <ni...@qb.com>.
I made a component for this purpose.

Here are the lines of the source code.

protected void renderComponent(IMarkupWrite writer, IRequestCycle  
cycle) {
	if (!cycle.isRewinding()) {
		PageRenderSupport pageRenderSupport =  
TapestryUtils.getPageRenderSupport(cycle,this);
		pageRenderSupport.addExternalScript(new ExternalResource(getJsURL 
(), null));
		if (!getInit() != null) {
			pageRenderSupport.addInitializationScrfipt(getInit());
		}
	}
	renderBody(writer, cycle);
}


Thank you taking your time.

Toshio

On 平成 18/11/21, at 0:40, Jesse Kuhnert wrote:

> Referencing a file path will never work. (esp not with ie) . You  
> should make
> that "local.js" a context or classpath relative resource and  
> reference it
> appropriately from there.
>
> On 11/20/06, andyhot <an...@di.uoa.gr> wrote:
>>
>> What's wrong with including
>>
>> <script type="text/javascript" language="javascript"
>> src="file://usr/local/lib/local.js"></script>
>>
>> directly into the tapestry template?
>>
>>
>>
>> Regarding PageRenderSupport.addExternalScript(), I believe you  
>> could call
>> it from a page or component passing a:
>> new ExternalResource("file://usr/local/lib/local.js", getLocale())
>>
>>
>>
>> NISHIMURA Toshio wrote:
>> > Hi,
>> >
>> > I have a problem handling javascript files. The original HTML is
>> following;
>> >
>> > <html>
>> > <head>
>> > <script type="text/javascript" language="javascript"
>> > src="common.js"></script>
>> > <script type="text/javascript" language="javascript"
>> > src="file://usr/local/lib/local.js"></script>
>> > </head>
>> > ...
>> >
>> > '/usr/local/lib/local.js' contains machine depended javascript
>> functions.
>> > In testing situation, I want to use the mock script instead of  
>> this.
>> > So I want to switch the source path of this script.
>> >
>> > I can implement the features of "common.js" with "@Script".
>> > But how can I implement "local.js"?
>> >
>> > I can't use "<include-script
>> > resource-path="file://usr/local/lib/local.js"/>"
>> > Because the 'resource-path' specifies the class path.
>> >
>> > "PageRenderSupport.addExternalScript()" may solve this problem,  
>> but I'm
>> > not sure how to use it.
>> >
>>
>> > Any help would be appreciated.
>> >
>> > Toshio
>> >
>> >  
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>>
>> --
>> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
>> Tapestry / Tacos developer
>> Open Source / J2EE Consulting
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> -- 
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

=== qbテレビ ===
Quality Broadband
西村 俊夫
Tel: 03-5777-2498
Fax: 03-5777-2497
Skype: toshio_nishimura




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


Re: handling extern-asset Javascript

Posted by Jesse Kuhnert <jk...@gmail.com>.
Referencing a file path will never work. (esp not with ie) . You should make
that "local.js" a context or classpath relative resource and reference it
appropriately from there.

On 11/20/06, andyhot <an...@di.uoa.gr> wrote:
>
> What's wrong with including
>
> <script type="text/javascript" language="javascript"
> src="file://usr/local/lib/local.js"></script>
>
> directly into the tapestry template?
>
>
>
> Regarding PageRenderSupport.addExternalScript(), I believe you could call
> it from a page or component passing a:
> new ExternalResource("file://usr/local/lib/local.js", getLocale())
>
>
>
> NISHIMURA Toshio wrote:
> > Hi,
> >
> > I have a problem handling javascript files. The original HTML is
> following;
> >
> > <html>
> > <head>
> > <script type="text/javascript" language="javascript"
> > src="common.js"></script>
> > <script type="text/javascript" language="javascript"
> > src="file://usr/local/lib/local.js"></script>
> > </head>
> > ...
> >
> > '/usr/local/lib/local.js' contains machine depended javascript
> functions.
> > In testing situation, I want to use the mock script instead of this.
> > So I want to switch the source path of this script.
> >
> > I can implement the features of "common.js" with "@Script".
> > But how can I implement "local.js"?
> >
> > I can't use "<include-script
> > resource-path="file://usr/local/lib/local.js"/>"
> > Because the 'resource-path' specifies the class path.
> >
> > "PageRenderSupport.addExternalScript()" may solve this problem, but I'm
> > not sure how to use it.
> >
>
> > Any help would be appreciated.
> >
> > Toshio
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> Tapestry / Tacos developer
> Open Source / J2EE Consulting
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com