Hm.

Why not pass your "menu" component a list of menu items? Then each page can 
define the menu items it wants?
You could do something like:
  <t:menu>
    <p:fruitmain>
        <t:menuitem ...>additional markup</t:menuitem>
    </p:fruitmain>
    <p:fruitother>
        <t:menuitem ...>additional markup</t:menuitem>
    </p:fruitother>
  </t:menu>

And now, inside of menu.tml, you can do something like:

<t:loop source="menuItems" value="item">
  <t:delegate to="item"/>
</t:loop>

menu.java:
  @Property
  private Block item;

  public List<Block> getMenuItems() {
      List<Block> blocks = new ArrayList<Block>();
      for(String name : resources.getInformalParameterNames()) {
          if (resources.getBoundType(name).isInstance(Block.class)) {
              blocks.add(resources.getBlockParameter(name));
          }
      }
      return blocks;
  }


In fact, you could even do something where the <t:menuitem> was in the <t:menu> 
component, and you just pass the block of additional items to render to the 
menuitem component, something like:

<t:menu>
  <p:fruitmain>fruit!</p:fruitmain>
</t:menu>

menu.tml:
  <t:loop source="menuItems" value=item">
     <t:menuitem item="item"/>
  </t:loop>

menuitem.java:
  @Parameter
  @Property
  private Block item;

menuitem.tml
  Some markup <t:delegate to="item"/> some more markup


A setup like that would result in: Some markup fruit! some more markup.

Anyway, your description is still a bit difficult to follow in terms of what, 
exactly, you're trying to accomplish. This is a case of "more specific would be 
better".

Robert

On Mar 13, 2012, at 3/134:13 PM , TechniciuM wrote:

> The thing is that I want to make components( each component has it's own menu
> ) and each component( menu ) corresponds to some particular page, so for
> instance if I had a meat menu component and fruit menu component, once
> clicked on fruit page it gives me just fruit menu. So I will somehow need to
> do 3 things, to create one class which will achieve that behavior, to create
> specific component classes, and to create tml class for shift behavior. 
> 
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/How-to-represent-this-tp5558903p5562600.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


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

Reply via email to