How to change layout layout in Tapestry 5 pages at runtime?

I have one layout component for all my pages, I want to switch this component based on the user's desire. I don't want to add a property to every page to return the current layout component.

+2


source to share


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







All Articles