tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Gusev (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TAP5-1864) Block renderer helper / service
Date Fri, 08 Nov 2013 07:51:18 GMT

    [ https://issues.apache.org/jira/browse/TAP5-1864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13817094#comment-13817094

Dmitry Gusev commented on TAP5-1864:

Rendering block is not that trivial, because, in general, block may require context for rendering.
And by context I mean parameters bindings. It's often happens that you first need to initialize
some properties of your page/component before you can render a block.

In my projects I usually create separate internal pages, usually one page per block. Then
I declare properties/parameters on that page which are consumed by block.

Then later in code I programmatically initialize properties for that page and trigger some
component event on that page so that the event handler return me a block or render it via
AjaxResponseRenderer. I use tapestry's AJAX functionality to grab generated event response
in JSON format that contains rendered HTML snippets which corresponds to rendered blocks.
Not sure if you can add CSS to response programmatically, but you can surely add JavaScripts
-- so all those JS contributions also can be found in the resulting JSON.

I've described this approach on the T5 mailing list few times with code snippets, here is
my blog entry about that: http://dmitrygusev.blogspot.ru/2013/04/render-tapestry5-block-to-string-from.html

> Block renderer helper / service
> -------------------------------
>                 Key: TAP5-1864
>                 URL: https://issues.apache.org/jira/browse/TAP5-1864
>             Project: Tapestry 5
>          Issue Type: New Feature
>          Components: tapestry-core
>    Affects Versions: 5.3.2
>            Reporter: Magnus Kvalheim
>         Attachments: RenderCommandToStringService.java, RenderCommandToStringServiceImpl.java
> I've seen several posts on the mailing lists asking for how to render blocks manually
in pages/components.
> Had a use case in this issue: https://issues.apache.org/jira/browse/TAP5-1863
> Basically I tried with:
> -------- 
> RenderCommand renderCommand = (RenderCommand)alertBlock; 
> MarkupWriter markupWriter = new MarkupWriterImpl(); 
> RenderQueueImpl renderQueue = new RenderQueueImpl(log); 
> renderQueue.push(renderCommand); 
> renderQueue.run(markupWriter); 
> alertManager.info(markupWriter.toString()); 
> -------- 
> Don't know if it's the 'correct' way of doing things so requesting a service or a helper
class available in core that does the job.

This message was sent by Atlassian JIRA

View raw message