Cmobilecom AF 5.19 Developer Guide

Embedded Objects - Menu

Menu is a tree of menu nodes. A menu node can link to a page, a URL address, or open a submenu. A menu can be embedded in a page in different styles, including menu bar, tiered menu, tree, and accordion tree.

Embed An XML Menu

Embed a menu that is defined in XML.

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="menu1" type="menu">
		<menuXml>filePath</menuXml>
	</object>
For example,
	/path/conference_agenda.xpg
		  year_2023/
				agenda.xmu
/path/conference_agenda.xpg:

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="agenda_menu_2023" type="menu">
		<menuXml>year_2023/agenda.xmu</menuXml>
	</object>

A menu in XML consists of a tree of menu items. A MenuNode object will be created for each menu item in XML.

For example,

<menu nameLocalized="true" urlBase="/userGuide" menuStyle="TREE" expandedDepth="2">
	<item name="Example1" url="examples/example1.html" />

	<item name="Example2" >
		<item name="Example2-1" url="examples/example2-1.html" />
		<item name="Example2-2" url="examples/example2-2.html" />
	</item>

	<item name="Example3" url="http://www.cmobilecom.com" target="_blank" />
	<item name="Example4" url="/foo/bar.html" />
</menu>
The menu xml can be inline under the object element. For example,

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="menu2" type="menu">

		<menu nameLocalized="true" urlBase="/userGuide" menuStyle="TREE" expandedDepth="3">
			<item name="Example1" url="examples/example1.html" />

			<item name="Example2" >
				<item name="Example2-1" url="examples/example2-1.html" />
				<item name="Example2-2" url="examples/example2-2.html" />
			</item>

			<item name="Example3" url="http://www.cmobilecom.com" target="_blank" />
			<item name="Example4" url="/foo/bar.html" />
		</menu>
	</object>
The relative URLs of menu items will be resolved by prepending urlBase as followings:
	Index                 (url="/userGuide/index.html")
		Example1          (url="/userGuide/examples/example1.html")
		Example2
			Example2-1    (url="/userGuide/examples/example2-1.html")
			Example2-2    (url="/userGuide/examples/example2-2.html")
		Example3          (url="http://www.cmobilecom.com", target="_blank")
		Example4          (url="/foo/bar.html")
If a resolved URL starts with / (not http or https), it is a URL under contextPath.
	https://domain:port/<contextPath>

Embed Menu From Hierarchy Entities

Hierarchy Entities can be embedded as tree-structure menu. For example, BookCategory entities are hierarchy entities. Clicking a book category will list all the books under the category.

	<object xmlns="http://www.cmobilecom.com/af/objects"
			id="book_categories" type="menu">
		<entityType>myModule.BKCAT</entityType>

		<viewConfig>
			<viewType>MENU</viewType>
			<menuStyle>TREE</menuStyle>
			<menuNode key="hierarchy.entity">
				<name>#{entity.name}</name>
				<renderStyle>
					<styleNumber>16</styleNumber>
				</renderStyle>
				<outputLink>/listBooks.xpg?category=#{entity.hierarchyId}</outputLink>
			</menuNode>

			<menuNode key="hierarchy.root">
				<name>#{bundle.AllBooks}</name>
				<renderStyle>
					<styleNumber>16</styleNumber>
				</renderStyle>
				<outputLink>/allBooks.xpg</outputLink>
			</menuNode>
		</viewConfig>
	</object>
DataType myModule.BKCAT is mapped to BookCategory entity type. Style number 16 is OUTPUT_LINK (defined in class RenderStyle).

For example, book categories as a tree menu:

	AllBooks
		Science
			Biology
			ComputerScience
				Compiler
				AI
		Fictions
		Arts
		Literatures
Embedded Objects: EntitiesEmbedded Objects: Partial Behavior SupportFrames / No Frames