You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by trsvax <tr...@gmail.com> on 2011/11/01 15:38:28 UTC

Re: Insert Stylesheet to the Head top

You should be able to do this with a MarkupRendererFilter

Here is an example of one that puts code after the body tag

https://github.com/trsvax/tapestry-facebook/blob/master/src/main/java/com/trsvax/tapestry/facebook/services/FBModule.java



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4955340.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Insert Stylesheet to the Head top

Posted by Peter Stavrinides <P....@albourne.com>.
Great explanation Robert!

Thanks,
Peter
----- Original Message -----
From: "Eugene Zhulkov" <ez...@gmail.com>
To: users@tapestry.apache.org
Sent: Wednesday, 2 November, 2011 14:30:19 GMT +02:00 Athens, Bucharest, Istanbul
Subject: Re: Insert Stylesheet to the Head top

It works! Thank you all very much!

Code:



Overall processing time for main page of http://kindershopping.ru hasn't
changed:
before - min 149ms, mean 165ms, max 195ms
after - min 144ms, mean 163ms, max 365ms
 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4957961.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
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


Re: Insert Stylesheet to the Head top

Posted by Eugene Zhulkov <ez...@gmail.com>.
It works! Thank you all very much!

Code:



Overall processing time for main page of http://kindershopping.ru hasn't
changed:
before - min 149ms, mean 165ms, max 195ms
after - min 144ms, mean 163ms, max 365ms
 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4957961.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Insert Stylesheet to the Head top

Posted by Robert Zeigler <ro...@roxanemy.com>.
Remember,it's a pipeline that works like:

filter a -> filter b -> filter c -> final filter
and then the flow returns /back up/ the chain of filters
filter c -> filter b -> filter a.

The filter that handles placing the resources into the document is "DocumentLinker". It's added fairly early in the chain. It sets up some environment variables, then passes control down the chain. It adds the stylesheets to the document when control returns to the filter. The idea is that all of the component rendering, etc. adds to a growing list of assets that DocumentLinker needs to place into the document, and only when all of that rendering is finished are they actually added to the document.  So by specifying after:*, you have:

filter a -> document linker (setup environment) -> ... -> your filter
and then
your filter -> ... -> document linker (add resources) -> filter a

So what you really want is not to be after:*, but to be before:DocumentLinker, and then it would work like:

filter a -> your filter -> document linker (setup environment) -> ... 
... -> document linker (add various stylesheets -> your filter (add your custom css file here) -> filter a

Ie, contribute it before:DocumentLinker, and then your filter code would be something like:

public void renderMarkup(MarkupWriter writer, MarkupRenderer delegate) {
  //pass control through to document linker, etc.
  delegate.renderMarkup(writer);
  //now add your custom stylesheet.
  writer.getDocument()...
}

HTH,

Robert

On Nov 2, 2011, at 11/26:40 AM , Eugene Zhulkov wrote:

> I used "after:*" parameter so filter is called last in the chain of filters
> according to debugger's info.
> Also I tried to override last filter - DefaultValidationDecorator, with no
> results.
> 
> It seems tapestry resources are inserted after these filters. Outside
> MarkupRendererFilter routines 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4957882.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> 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


Re: Insert Stylesheet to the Head top

Posted by Eugene Zhulkov <ez...@gmail.com>.
I used "after:*" parameter so filter is called last in the chain of filters
according to debugger's info.
Also I tried to override last filter - DefaultValidationDecorator, with no
results.

It seems tapestry resources are inserted after these filters. Outside
MarkupRendererFilter routines 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4957882.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Insert Stylesheet to the Head top

Posted by Barry Books <tr...@gmail.com>.
My first guess would be you need to add an order to configuration.add
to make sure you run last (or at least after tapestry does it's thing)

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


Re: Insert Stylesheet to the Head top

Posted by Eugene Zhulkov <ez...@gmail.com>.
I've tried this code:



So as you can see I've added new filter which inserts <link> element after
html/head element. It works fine - this link appears in the resulting page.
But system resources (css and js) are being processed later by tapestry and
inserted before my resources... 

Any ideas?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4957823.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Insert Stylesheet to the Head top

Posted by Eugene Zhulkov <ez...@gmail.com>.
Thank you for reply,

I'll try it but think it will drastically increase overall processing
time...  

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Insert-Stylesheet-to-the-Head-top-tp4952484p4955357.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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