How to change layout layout in Tapestry 5 pages at runtime?
1 answer
Assuming you have a fixed number of layouts, you can use blocks. Your layout.tml will look something like this:
<t:delegate to="layout"/>
<t:block id="layout1">
<body>...</body>
</t:block>
<t:block id="layout2">
<body>...</body>
</t:block>
In your layout .java will be:
public Object getLayout() {
if (...) {
return _layout1;
} else {
return _layout2;
}
}
@Inject
private Block _layout1;
@Inject
private Block _layout2;
+3
source to share