Re: T5: Rendering a block via the DOM
Wow, Josh. Thanks, that's a lot of work! I'll try. On Fri, Apr 18, 2008 at 6:53 PM, Josh Canfield <[EMAIL PROTECTED]> wrote: > I'm not sure if there is an easier way to do this, but you could > configure a MarkupRendererFilter that finds and moves your elements > before the page is written. This is how pageRenderSupport.addScript > works, sortof... > > Here's something I whipped up. You could push something on the > environment to store ids instead of adding an attribute. While I ran > this, and it works, it's not guaranteed to be future proof, without > bugs or the smartest way to do the task... enjoy! > > public void contributeMarkupRenderer( >OrderedConfiguration configuration) { >MarkupRendererFilter bodyMover = new MarkupRendererFilter() { >public void renderMarkup(MarkupWriter writer, > MarkupRenderer renderer) { >renderer.renderMarkup(writer); > >Document document = writer.getDocument(); >Element html = document.getRootElement(); >Element body = html.find("body"); >if (body == null) return; // no body no moving >processNode(html, body); >} >private void processNode(Node node, Element body) { >List children = node.getChildren(); >for (int i = 0; i < children.size(); ++i) { >Node child = children.get(i); >if (!(child instanceof Element)) >continue; >Element element = (Element) child; >if > (element.getAttribute("move-to-before-body") != null) { >children.remove(i); >body.getChildren().add(child); >--i; // one less element >} else { >processNode(child, body); >} >} >} >}; >configuration.add("bodyMover", bodyMover); > } > > On Fri, Apr 18, 2008 at 3:15 PM, Bill Holloway <[EMAIL PROTECTED]> wrote: > > I have a component that picks up a Block via > > componentResources.getBlockParameter(String). No problem. But I need > to > > render this Block at the very bottom of the overall page, right before > the > > . > > > > Any thoughts? > > > > -- > > Bill @ PeoplePad > > > > > > -- > -- > TheDailyTube.com. Sign up and get the best new videos on the internet > delivered fresh to your inbox. > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Bill @ PeoplePad
Re: T5: Rendering a block via the DOM
I'm not sure if there is an easier way to do this, but you could configure a MarkupRendererFilter that finds and moves your elements before the page is written. This is how pageRenderSupport.addScript works, sortof... Here's something I whipped up. You could push something on the environment to store ids instead of adding an attribute. While I ran this, and it works, it's not guaranteed to be future proof, without bugs or the smartest way to do the task... enjoy! public void contributeMarkupRenderer( OrderedConfiguration configuration) { MarkupRendererFilter bodyMover = new MarkupRendererFilter() { public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) { renderer.renderMarkup(writer); Document document = writer.getDocument(); Element html = document.getRootElement(); Element body = html.find("body"); if (body == null) return; // no body no moving processNode(html, body); } private void processNode(Node node, Element body) { List children = node.getChildren(); for (int i = 0; i < children.size(); ++i) { Node child = children.get(i); if (!(child instanceof Element)) continue; Element element = (Element) child; if (element.getAttribute("move-to-before-body") != null) { children.remove(i); body.getChildren().add(child); --i; // one less element } else { processNode(child, body); } } } }; configuration.add("bodyMover", bodyMover); } On Fri, Apr 18, 2008 at 3:15 PM, Bill Holloway <[EMAIL PROTECTED]> wrote: > I have a component that picks up a Block via > componentResources.getBlockParameter(String). No problem. But I need to > render this Block at the very bottom of the overall page, right before the > . > > Any thoughts? > > -- > Bill @ PeoplePad > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Rendering a block via the DOM
I have a component that picks up a Block via componentResources.getBlockParameter(String). No problem. But I need to render this Block at the very bottom of the overall page, right before the . Any thoughts? -- Bill @ PeoplePad