Accessing Menu Items Directly
When iterating through menus, either using the
menu:iterate
tag, or view:iterate
tag, the items exposed by the iteration are all
com.escenic.menu.MenuItem
objects. You can use inline
Java code to directly access these objects.
You could, for example, use code like this to display images for items that have them:
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="LOGIC"%> . . . <MENU:use id="menu" treeName="main"> <VIEW:iterate id="menuItem"> <LOGIC:present name="menuItem" property="imageURL"> <img src="<%=menuItem.getImageURL()%>"> </LOGIC:present> <LOGIC:notPresent name="menuItem" property="imageURL"> <%=menuItem.getText()%> </LOGIC:notPresent> </VIEW:iterate> </MENU:use>
It is also possible to use the MenuItem
obejcts
to access the Escenic objects they reference. This code, for example
renders some of the content of a section:
<LOGIC:present name="menuItem" property="sectionId"> <BEAN:define id="menusection" name="menuItem" property="section"/> <SECTION:use name="menusection"> <TEMPLATE:insert typeName="group" groupName="menu" /> </SECTION:use> </LOGIC:present>
logic:present
is used to check whether the
current menu item references a section. If it does, then the section is
retrieved and displayed as part of the menu.