VerticalMenu demo

Description
This page displays a verticalmenu component.
The defaultActiveItem parameter must be set to select the default menu item.

Notice that the content of verticalMenuItem can be :
  • A Tapestry component
  • A list of li elements
  • Or any HTML content...
Notice that the event triggered by verticalmenu component can be handle to achieve the page navigation.


In Action
This is the second menu item
with long HTML content



TML Source code

	<div style="width: 200px;">		
	<ex:verticalMenu t:id="verticalmenu" defaultActiveItem="example1">
		<ex:verticalMenuItem t:id="example1" t:title="literal:Example 1">
  			<ul>
  				<li><t:pagelink page="components/verticalMenu/Example1">Example 1</t:pagelink></li>
  				<li><t:pagelink page="index">Back to index</t:pagelink></li>
  			</ul>
  		</ex:verticalMenuItem>
		<ex:verticalMenuItem t:id="item2" t:title="literal:Item 2">
  			This is the second menu item
  			<br /> with long HTML content
  		</ex:verticalMenuItem>
  		<ex:verticalMenuItem t:id="external" 
  		                     t:title="literal:Google" 
  		                     t:icon="asset:context:/img/verticalMenu/google-ico.png" 
  		                     t:target="_blank" />
	</ex:verticalMenu>
	</div>
	



Java code

    	@Inject
    	private PageRenderLinkSource pageLinkSource;

    	@InjectComponent
    	private VerticalMenu verticalMenu;

    	@OnEvent(ExanpeEventConstants.VERTICALMENU_EVENT)
    	Object handleSelectMenu(String menuId)
    	{
        	if ("external".equals(menuId))
        	{
	        		URL external = null;
	           	try
	        	{
	        		external = new URL("http://www.google.fr");
	        	}
	        	catch (MalformedURLException ex)
	        	{
	        		throw new RuntimeException(ex);
	        	}
	        	verticalMenu.resetSelectedMenuItem();
	        	return external;
        	}
        	if ("example1".equals(menuId)) 
        	{ 
        		return pageLinkSource.createPageRenderLink(Example1.class); 
        	}
        	
        	return this;
    	}