You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Casey Link <ca...@outskirtslabs.com> on 2016/05/04 17:54:03 UTC

Rendering a component programmatically

Hi folks,

This is probably a long shot, but is it possible to render a component
(and its template) to DOM and eventually a String of markup?

I'm using the DataTables component from tapestry5-jquery [0] in ajax
mode. For the most part it uses standard tapestry elements (BeanModel,
GridDataSource, etc). However in ajax mode the entire contents of the
table is fed back to the DataTables jquery plugin via ajax as JSON in a
special format the plugin epects So rendering parameter blocks (i.e.,
<p:actionsCell>) doesn't work. The "render the block from server-side"
bit here doesn't work for components or page links [1]

Rendering PropertyConduits works normally, and I've even created some
custom PropertyConduits that return some markup rendering pagelinks and
such. But I'd really like to reuse some simple button group components.

I'd love to be able to do something like:

MyComponent myComponent = new MyComponent(paramters)
Dom/String renderedDom = myComponent.render();

Is there any way to do this?

Casey

[0]: http://tapestry5-jquery.com/components/docsdatatables
[1]:
https://github.com/got5/tapestry5-jquery/blob/efc38f955a5494cce18dfdd4553550b2963d6800/src/main/java/org/got5/tapestry5/jquery/internal/DefaultDataTableModel.java#L326

-- 
Casey Link

Outskirts Labs { https://outskirtslabs.com }
Technology for Changemakers


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


Re: Rendering a component programmatically

Posted by Casey Link <ca...@outskirtslabs.com>.
Holy crap! This is exactly what I needed, and it just works.

If I could suggest adding the keyword "programmatically" to those docs,
as I searched extensively and didn't find it.

Thanks for the incredibly fast response.

Casey Link

Outskirts Labs { https://outskirtslabs.com }
Technology for Changemakers

On 05/04/2016 08:07 PM, Thiago H de Paula Figueiredo wrote:
> On Wed, 04 May 2016 14:54:03 -0300, Casey Link
> <ca...@outskirtslabs.com> wrote:
>> Hi folks,
>
> Hi!
>
>> This is probably a long shot, but is it possible to render a component
>> (and its template) to DOM and eventually a String of markup?
>
> Yes! Use the PartialTemplateRenderer service:
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PartialTemplateRenderer.html.
> Example:
> https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PartialTemplateRendererDemo.java
>


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


Re: Rendering a component programmatically

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 04 May 2016 14:54:03 -0300, Casey Link <ca...@outskirtslabs.com>  
wrote:
> Hi folks,

Hi!

> This is probably a long shot, but is it possible to render a component
> (and its template) to DOM and eventually a String of markup?

Yes! Use the PartialTemplateRenderer service:  
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/PartialTemplateRenderer.html.  
Example:  
https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/PartialTemplateRendererDemo.java

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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