You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dimitris Zenios <di...@gmail.com> on 2011/10/09 11:54:44 UTC

JavascriptStack

Hi guys.I have a javascript stack which includes two javascript files.
One should be always added and the other only when internet explorer.
Is there a possibility to append the internet explorer javascript file
only when needed or it should be always added?

Dimitris Zenios

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


Re: JavascriptStack

Posted by Martin Strand <do...@gmail.com>.
The User-Agent header is very unreliable (unless this is for an intranet)  
and you would also need to add "Vary: User-Agent" to defeat caching by  
shared proxies.

It's probably better to use two stacks instead, and include the IE stack  
with a conditional comment.
For example, I use this "IERepair" component to add ifixpng for <=IE6 and  
selectivizr/css3pie for <=IE8 :


public class IERepair
{
	@Inject
	private JavaScriptStackPathConstructor stackPathConstructor;

	boolean beginRender(MarkupWriter writer)
	{
		writer.writeRaw("<!--[if lte IE 6]>");
		renderStack(writer, IE6_STACK);
		writer.writeRaw("<![endif]-->");

		writer.writeRaw("<!--[if lte IE 8]>");
		renderStack(writer, IE8_STACK);
		writer.writeRaw("<![endif]-->");

		return false;
	}

	private void renderStack(MarkupWriter writer, String stack)
	{
		List<String> paths =  
stackPathConstructor.constructPathsForJavaScriptStack(stack);
		for (String path : paths)
		{
			writer.element("script", "type", "text/javascript", "src", path);
			writer.end();
		}
	}
}


On Sun, 09 Oct 2011 12:40:52 +0200, François Facon  
<fr...@atos.net> wrote:

> Hi Dimitris,
>
> Perphas a perThread service could detect with the useragent header if
> the browser used by the client is IE. by injecting this service to
> stack, you could use it to verify if you have to  add the js when the
> method getJavaScriptLibraries get called .
>
> Regards
> François
>
> 2011/10/9 Dimitris Zenios <di...@gmail.com>:
>> Hi guys.I have a javascript stack which includes two javascript files.
>> One should be always added and the other only when internet explorer.
>> Is there a possibility to append the internet explorer javascript file
>> only when needed or it should be always added?
>>
>> Dimitris Zenios

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


Re: JavascriptStack

Posted by François Facon <fr...@atos.net>.
Hi Dimitris,

Perphas a perThread service could detect with the useragent header if
the browser used by the client is IE. by injecting this service to
stack, you could use it to verify if you have to  add the js when the
method getJavaScriptLibraries get called .

Regards
François

2011/10/9 Dimitris Zenios <di...@gmail.com>:
> Hi guys.I have a javascript stack which includes two javascript files.
> One should be always added and the other only when internet explorer.
> Is there a possibility to append the internet explorer javascript file
> only when needed or it should be always added?
>
> Dimitris Zenios
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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