Doing it exactly as you want won't work (as pointed out by Kris), but you can accomplish the same thing using the delegate component.
I would recommend something like:
create a single layout component that hides the complexity from the rest of the app.
That layout component takes a parameter "layout" or "name:" or whatever.
So, you use your layout component like:
<div t:type="layout" layout="default">
...
</div>


The layout component structure will depend on the complexity of your application. For example, will layouts be "pluggable"? Or is there a set number of layouts? In any event, the overall structure for your layout component is going to be:
<t:delegate to="layoutComponent">
...
</t:delegate>

Then your java class will have a:
public Object getLayoutComponent() {
}
method. And that method is responsible for determining which layout is used. For the simple case where there are several layouts, but they are known ahead of time, you can put each layout into your layout component, like:

<t:block id="layout1">
...
</t:block>

<t:block id="layout2">
...
</t:block>

And your getLayoutComponent() method would look something like:
public Object getLayoutComponent() {
  return _componentResources.getBlock(_layout);
}

Where _componentResources is an injected variable of type ComponentResources, and _layout is your String layout parameter for the component.

That's the simple case. For the more complicated case of pluggable layouts, you can play the same game, except that you would acquire the blocks not from the current component template, but from some other page (which is, in fact, legal. :)


Cheers,

Robert

On Nov 13, 2007, at 11/131:54 AM , Kristian Marinkovic wrote:

hi harald,

want you ask for is not doable in Tapestry... for good reason :)
(please search the mailing list for static structure dynamic behvior)


part of what you want can be achieved with a Delegate
component. you'd have to declare you layout specific
components in your Layout component within a Block
and display one of these components using a Delegate.

g,
kris




Harald Graf <[EMAIL PROTECTED]>
12.11.2007 16:15
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>


An
Tapestry users <users@tapestry.apache.org>
Kopie

Thema
[T5] Dynamic Layouts]









hi all,

is there any possibility to use dynamic layouts for example, i'd like to
use some variable for my
layout name (${layout} which is then filled in my pageclass at runtime
depending on some conditions.

<html t:type="${layout}" xmlns:t="
http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
</html>

thank you,
harald





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to