You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by donf yang <do...@gmail.com> on 2009/06/11 15:20:49 UTC
Re: Two Menu Components
codes fragements:
Main.tml
<div t:type="zone" id="majorMenuZone">
<t:MyMenu majorMenus="menuSource">
<div t:type="zone" id="subMenuZone"/>
</t:MyMenu>
</div>
<t:Block t:id="subMenuBlock1" ><a href="">sub1-menu1</a> <a
href="">sub1-menu2</a></t:Block>
<t:Block t:id="subMenuBlock2" ><a href="">sub2-menu1</a> <a
href="">sub2-menu2</a></t:Block>
-----------------------------------Main.java-----------------------------------
//Provide menu source, key-title of sub menu | value - content block of sub
menu
@Inject
Block subMenuBlock1, subMenuBlock2;
Map getMenuSource(){
Map<String, Block> menuSource = new HashMap<String, Block>();
menuSource.put("submenu1title",subMenuBlock1 );
menuSource.put("submenu2title",subMenuBlock2 );
}
-----------------------------------MyMenu.java
-----------------------------------
@Parameter
private Map majorMenus;
private String submenuId;
//If u got a style on majormenu, return MyMenu
Object onShowSubMenu(String submenuId){
this.submenuId = submenuId;
return majorMenus.get(submenuId);
//or return MainMenu
}
-----------------------------------MyMenu.tml
-----------------------------------
<t:Loop>
//loop major menu titles here, and create component event "showSubMenu" ,
link one of zones.
</t:Loop>
There are 2 ways to refresh your menus:
1. return MyMenu to refresh the whole things of your menu component
2. return content block of your submenu, and you can return a
MultiZoneUpdate anyway.
On Thu, Jun 11, 2009 at 8:26 PM, Eldred Mullany <
eldred.mullany@easypay.co.za> wrote:
> Hi All
>
>
>
> I need some advice on how to get two menu components to talk to each
> other. The fist component is a top menu with a whole lot of links, when
> an action link is fired(from the first menu component) I want to pass a
> parameter string to the second component (sub-menu) which will render
> based on the parameter it's been passed to it.
>
>
>
> So in other words second menu component is dependent on the first.
>
>
>
> Its pretty much high level but some advice would be useful. Perhaps a
> component listener of some sort?
>
>
>
> Any ideas ?
>
>
>
> Thanks
>
> Eldred
>
>
>
>
--
Regards,
Donf Yang
------------------------------------------------------------------------------
To be surprised,to wonder,is to begin to understand.
RE: Two Menu Components
Posted by Eldred Mullany <el...@easypay.co.za>.
Thanks Donf and Otho, my two menu components work like a charm. I used
the MultiZoneUpdate method. I now have a very interactive menu system !
-----Original Message-----
From: donf yang [mailto:donf.yang@gmail.com]
Sent: Thursday, June 11, 2009 3:31 PM
To: Tapestry users
Subject: Re: Two Menu Components
Oh, some mistakes:
<t:Block> - > <t:block>
-----------------------------------MyMenu.java
-----------------------------------
Object onShowSubMenu(String submenuId){
this.submenuId = submenuId;
//It's depends on which zone u linked
//MultiZoneUpdate multiZoneUpdatenew = new
MultiZoneUpdate("majorMenuZone", this);
MultiZoneUpdate multiZoneUpdatenew = new
MultiZoneUpdate("subMenuZone",
majorMenus.get(submenuId));
return multiZoneUpdatenew;
}
On Thu, Jun 11, 2009 at 9:20 PM, donf yang <do...@gmail.com> wrote:
> codes fragements:
>
> Main.tml
> <div t:type="zone" id="majorMenuZone">
> <t:MyMenu majorMenus="menuSource">
> <div t:type="zone" id="subMenuZone"/>
> </t:MyMenu>
> </div>
>
> <t:Block t:id="subMenuBlock1" ><a href="">sub1-menu1</a> <a
> href="">sub1-menu2</a></t:Block>
> <t:Block t:id="subMenuBlock2" ><a href="">sub2-menu1</a> <a
> href="">sub2-menu2</a></t:Block>
>
>
>
>
-----------------------------------Main.java----------------------------
-------
> //Provide menu source, key-title of sub menu | value - content block
of sub
> menu
>
> @Inject
> Block subMenuBlock1, subMenuBlock2;
>
> Map getMenuSource(){
> Map<String, Block> menuSource = new HashMap<String, Block>();
> menuSource.put("submenu1title",subMenuBlock1 );
> menuSource.put("submenu2title",subMenuBlock2 );
> }
>
>
> -----------------------------------MyMenu.java
> -----------------------------------
> @Parameter
> private Map majorMenus;
> private String submenuId;
>
> //If u got a style on majormenu, return MyMenu
> Object onShowSubMenu(String submenuId){
> this.submenuId = submenuId;
> return majorMenus.get(submenuId);
> //or return MainMenu
> }
> -----------------------------------MyMenu.tml
> -----------------------------------
> <t:Loop>
> //loop major menu titles here, and create component event
"showSubMenu" ,
> link one of zones.
> </t:Loop>
>
> There are 2 ways to refresh your menus:
> 1. return MyMenu to refresh the whole things of your menu component
> 2. return content block of your submenu, and you can return a
> MultiZoneUpdate anyway.
> On Thu, Jun 11, 2009 at 8:26 PM, Eldred Mullany <
> eldred.mullany@easypay.co.za> wrote:
>
>> Hi All
>>
>>
>>
>> I need some advice on how to get two menu components to talk to each
>> other. The fist component is a top menu with a whole lot of links,
when
>> an action link is fired(from the first menu component) I want to pass
a
>> parameter string to the second component (sub-menu) which will render
>> based on the parameter it's been passed to it.
>>
>>
>>
>> So in other words second menu component is dependent on the first.
>>
>>
>>
>> Its pretty much high level but some advice would be useful. Perhaps a
>> component listener of some sort?
>>
>>
>>
>> Any ideas ?
>>
>>
>>
>> Thanks
>>
>> Eldred
>>
>>
>>
>>
>
>
> --
>
> Regards,
>
> Donf Yang
>
>
------------------------------------------------------------------------
------
> To be surprised,to wonder,is to begin to understand.
>
--
Regards,
Donf Yang
------------------------------------------------------------------------
------
To be surprised,to wonder,is to begin to understand.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Two Menu Components
Posted by donf yang <do...@gmail.com>.
Oh, some mistakes:
<t:Block> - > <t:block>
-----------------------------------MyMenu.java
-----------------------------------
Object onShowSubMenu(String submenuId){
this.submenuId = submenuId;
//It's depends on which zone u linked
//MultiZoneUpdate multiZoneUpdatenew = new
MultiZoneUpdate("majorMenuZone", this);
MultiZoneUpdate multiZoneUpdatenew = new MultiZoneUpdate("subMenuZone",
majorMenus.get(submenuId));
return multiZoneUpdatenew;
}
On Thu, Jun 11, 2009 at 9:20 PM, donf yang <do...@gmail.com> wrote:
> codes fragements:
>
> Main.tml
> <div t:type="zone" id="majorMenuZone">
> <t:MyMenu majorMenus="menuSource">
> <div t:type="zone" id="subMenuZone"/>
> </t:MyMenu>
> </div>
>
> <t:Block t:id="subMenuBlock1" ><a href="">sub1-menu1</a> <a
> href="">sub1-menu2</a></t:Block>
> <t:Block t:id="subMenuBlock2" ><a href="">sub2-menu1</a> <a
> href="">sub2-menu2</a></t:Block>
>
>
>
> -----------------------------------Main.java-----------------------------------
> //Provide menu source, key-title of sub menu | value - content block of sub
> menu
>
> @Inject
> Block subMenuBlock1, subMenuBlock2;
>
> Map getMenuSource(){
> Map<String, Block> menuSource = new HashMap<String, Block>();
> menuSource.put("submenu1title",subMenuBlock1 );
> menuSource.put("submenu2title",subMenuBlock2 );
> }
>
>
> -----------------------------------MyMenu.java
> -----------------------------------
> @Parameter
> private Map majorMenus;
> private String submenuId;
>
> //If u got a style on majormenu, return MyMenu
> Object onShowSubMenu(String submenuId){
> this.submenuId = submenuId;
> return majorMenus.get(submenuId);
> //or return MainMenu
> }
> -----------------------------------MyMenu.tml
> -----------------------------------
> <t:Loop>
> //loop major menu titles here, and create component event "showSubMenu" ,
> link one of zones.
> </t:Loop>
>
> There are 2 ways to refresh your menus:
> 1. return MyMenu to refresh the whole things of your menu component
> 2. return content block of your submenu, and you can return a
> MultiZoneUpdate anyway.
> On Thu, Jun 11, 2009 at 8:26 PM, Eldred Mullany <
> eldred.mullany@easypay.co.za> wrote:
>
>> Hi All
>>
>>
>>
>> I need some advice on how to get two menu components to talk to each
>> other. The fist component is a top menu with a whole lot of links, when
>> an action link is fired(from the first menu component) I want to pass a
>> parameter string to the second component (sub-menu) which will render
>> based on the parameter it's been passed to it.
>>
>>
>>
>> So in other words second menu component is dependent on the first.
>>
>>
>>
>> Its pretty much high level but some advice would be useful. Perhaps a
>> component listener of some sort?
>>
>>
>>
>> Any ideas ?
>>
>>
>>
>> Thanks
>>
>> Eldred
>>
>>
>>
>>
>
>
> --
>
> Regards,
>
> Donf Yang
>
> ------------------------------------------------------------------------------
> To be surprised,to wonder,is to begin to understand.
>
--
Regards,
Donf Yang
------------------------------------------------------------------------------
To be surprised,to wonder,is to begin to understand.