[Tapestry5] Tapestry5.2.6框架的TapestryModule类的contributeMarkupRenderer方法是谁调用的,有没有谁知道~~
cbigbird
2013-07-31
【提要】
在研究页面类引入的Javascript和css是如何写入到页面的时候遇到的一个问题。 【目前知道的】 发现调用层次大致如下: (1)TapestryModule类:contributeMarkupRenderer方法: MarkupRendererFilter documentLinker = new MarkupRendererFilter() { public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { DocumentLinkerImpl linker = new DocumentLinkerImpl(omitGeneratorMeta, tapestryVersion, compactJSON); environment.push(DocumentLinker.class, linker); renderer.renderMarkup(writer); environment.pop(DocumentLinker.class); linker.updateDocument(writer.getDocument()); } }; (2)DocumentLinkerImpl类:updateDocument方法: public void updateDocument(Document document) { Element root = document.getRootElement(); // If the document failed to render at all, that's a different problem and is reported elsewhere. if (root == null) return; addStylesheetsToHead(root, includedStylesheets); // only add the generator meta only to html documents boolean isHtmlRoot = root.getName().equals("html"); if (!omitGeneratorMetaTag && isHtmlRoot) { Element head = findOrCreateElement(root, "head", true); head.element("meta", "name", "generator", "content", tapestryBanner); } addScriptElements(root); } (3)DocumentLinkerImpl类:addStylesheetsToHead方法: …… Element head = findOrCreateElement(root, "head", true); …… Element container = head.elementAt(0, "stylesheet-link-container"); 【我的疑问】 TapestryModule类的contributeMarkupRenderer方法是谁调用的呢? |
|
superaxis
2013-08-01
是由tapestry-ioc调用
|
|
cbigbird
2013-08-01
superaxis 写道 是由tapestry-ioc调用
确实,以Renderer结尾的函数名,应该是IOC调用。 记得官网有Tapestry5 IOC的介绍,多谢你的提醒。 |
|
东方胜
2013-08-01
![]() |
|
superaxis
2013-08-02
cbigbird 写道 superaxis 写道 是由tapestry-ioc调用
确实,以Renderer结尾的函数名,应该是IOC调用。 记得官网有Tapestry5 IOC的介绍,多谢你的提醒。 并不是以Renderer结尾的函数由ioc调用,而是contribute开头的方法被调用,这种调用是隐式调用,还可以通过@Contribute注解进行显示声明。 |