You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by egarcia-sms <eg...@swissms.ch> on 2012/05/18 17:10:42 UTC

Rendering another component inside a component

Hi.

I've implemented a component in Tapestry 5, and I need my component to use
<t:actionlink> for some of its rendering, but of course, just using
writer.element("t:actionlink", ...) doesn't work.

What is the preferred approach to render a few components inside another
custom one?

Thanks in advance!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Rendering-another-component-inside-a-component-tp5711980.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Rendering another component inside a component

Posted by egarcia-sms <eg...@swissms.ch>.
I'm doing a tree rendering, so I don't think I can use a tml file only, as
the documentation suggested using a component for that. Problem is, when
generating my links manually I don't know the path I'm in, and I cannot use
a relative path.

I'll try your suggestions, thanks a lot!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Rendering-another-component-inside-a-component-tp5711980p5712954.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Rendering another component inside a component

Posted by Lance Java <la...@googlemail.com>.
One of Tapestry's principles is static structure and dynamic behaviour so
components can't be created at runtime. The MarkupWriter is for writing
HTML, not TML.

Can you do what you want in a tml file instead?


If not, you can do it programatically like this:

Component.tml
-------------
<t:block t:id="block">
	<t:eventlink event="foo">doFoo</t:eventlink>
</t:block>

Component.java
--------------
@InjectComponent
private Block block;

public RenderCommand beginRender() {
	return new RenderCommand() {
		public void render(MarkupWriter writer, RenderQueue queue) {
			queue.push(new RenderCommand(){
				public void render(MarkupWriter writer, RenderQueue queue) {
					// do stuff after the block
				}
			});
			queue.push(typeCoercer.coerce(block, RenderCommand.class);
			queue.push(new RenderCommand(){
				public void render(MarkupWriter writer, RenderQueue queue) {
					// do stuff before the block
				}
			});
		}
	};
}


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Rendering-another-component-inside-a-component-tp5711980p5712003.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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