You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by "Lance (JIRA)" <ji...@apache.org> on 2013/11/11 16:58:22 UTC
[jira] [Comment Edited] (TAP5-1864) Block renderer helper / service
[ https://issues.apache.org/jira/browse/TAP5-1864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13819052#comment-13819052 ]
Lance edited comment on TAP5-1864 at 11/11/13 3:58 PM:
-------------------------------------------------------
Something like this:
{code}
package foo.bar.components;
public class ToString {
@Property
private Binding value;
@Property
private MarkupHandler handler;
void setupRender() {
if (value == null && handler == null) {
throw new IllegalStateException("value or handler must be specified");
}
writer.element("deleteme");
}
// let the body render
void afterRender(MarkupWriter writer) {
Element container = writer.getElement();
writer.end();
String markup = container.getChildMarkup();
container.remove();
if (value != null) {
value.set(markup);
}
if (handler != null) {
handler.handle(markup);
}
}
}
{code}
was (Author: uklance):
Something like this:
{code}
package foo.bar.components;
public class ToString {
@Property
private Binding value;
@Property
private MarkupHandler handler;
void setupRender() {
if (value == null && handler == null) {
throw new IllegalStateException("value or handler must be specified");
}
}
void beforeRender(MarkupWriter writer) {
writer.element("deleteme");
}
void afterRender(MarkupWriter writer) {
Element container = writer.getElement();
writer.end();
String markup = container.getChildMarkup();
container.remove();
if (value != null) {
value.set(markup);
}
if (handler != null) {
handler.handle(markup);
}
}
}
{code}
> 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
(v6.1#6144)