One node in the platform's navigation menu tree, built fresh per user and root folder and cached briefly by MenuManager. Templates walk it from the root item ("menuRoot") through getItems and getVisible to render the admin and website navigation, and Java menu contributors and app declarations in controllers.xml populate it by calling getOrCreate on the node they attach to. Newer accounts group many of the old top level items into named admin menu sections, and presentAs lets a section temporarily answer to each of the legacy ids it replaced so those existing contributors keep working without changes.

Implements: Comparable


Properties

PropertyReturnsDescription
activebooleanApplications indicate the current active id by calling MenuItem.setActiveId when the resource is located. A section is also active when a page has declared itself active under one of the ids that section replaced, since most pages still name the old root.
activeItemsMenuItemListBuilds a new list containing only this item's children that are currently active, as reported by isActive.
canonicalIdStringThe item's real id, unaffected by presentAs. Use this whenever the answer must not depend on which identity a section is currently wearing, for example looking the item up in the section registry or keying anything persistent off it.
configItemMenuConfigItemThe account level menu configuration entry associated with this item, if any.
cssClassStringThe CSS classes rendered on this menu item, normally used to select its icon.
hiddenbooleanWhether this item is excluded from the visible menu.
hrefStringThe link this menu item points to.
idStringThe id contributors see. Normally the item's own id, but while a section is being offered under one of the ids it replaced this returns that legacy id, so code dispatching on it continues to work.
itemsMenuItemListThis item's children, building them on first access by asking the MenuManager to append this item's menu contributions. Subsequent calls return the same, already built list.
keywordsSet<String>Extra terms the menu's filter box matches this item on, beyond its own label. A hub page is the case this exists for: "Databases and storage" is where JSON Data went, so someone typing "json" has to land on it, and the label cannot say every name it absorbed. Keywords are held lowercase, since the filter lowercases what is typed. There are two additive sources: an app declares its own on the menu element in controllers.xml, and the platform holds them per id in AdminMenuSections, which is what reaches items an app version predating the restructure declared, as well as Java declared items.
keywordsCsvStringThe item's keywords as a comma separated list, for rendering into the menu markup.
menuApplicationsList<MenuApplication>The active menu applications that were resolved when the menu tree this item belongs to was built.
orderingintWhere this item sorts among its siblings. Lower values sort first; the default is 100.
orgRolesSet<Role>The roles the current user holds within the organisation this menu was built for.
originIdentityStringThe id of the parent that the contributing code was addressing when it added this item. For a section built out of several old roots this records which one the item came from, which is what lets the section group its items by origin instead of interleaving them. Normally the parent's own id, but a legacy id when the item was added during one of the parent's legacy identity passes.
rootFolderRootFolderThe root folder of the current request, used when deciding whether admin menu sections apply.
searchOnlyList<MenuItem>Items which are not in the menu, but are rendered hidden so that its filter can still find them. A suppressed page is reached from a link on the page it belongs to, which costs someone who already knows the page they want two clicks - the page it now lives behind, then the page. Keeping them here lets the menu filter match them directly, and the admin theme keeps them out of sight until it does. See {@code AdminMenuSections.isSuppressed} for what is suppressed and why. Held apart from {@link #getItems()} rather than marked hidden inside it, because two things depend on a suppressed item being out of that list. The admin theme is a versioned app and older versions render items without filtering hidden, so every suppressed page would reappear in the menu of an account that has not upgraded; and a section is pruned when empty by counting items, so a section made up entirely of suppressed pages would stop being pruned. Only the current theme reads this list.
textStringThe label rendered for this menu item.
userProfileThe currently signed in profile, as seen by KademiSecurityManager.
visibleList<MenuItem>This item's children that are not hidden, computed once and cached. Any exception raised while building the list is logged and swallowed, yielding an empty list rather than failing the page render.

Methods

getActiveItems() · getId() · getCanonicalId() · presentAs(String aliasId, Runnable work) · getText() · setText(String text) · text(String s) · getOrdering() · setOrdering(int ordering) · getHref() · setHref(String href) · getKeywords() · getKeywordsCsv() · addKeywords(Collection<String> toAdd) · addKeywords(String csv) · getCssClass() · setCssClass(String cssClass) · isHidden() · setHidden(boolean hidden) · isActive() · getItems() · getVisible() · peekItems() · add(String id) · getOriginIdentity() · setOriginIdentity(String originIdentity) · getOrCreate(String id, String text) · getOrCreate(String id, String text, Path p) · getOrCreate(String id, String text, String href) · getOrCreate(String id, String text, String href, String css) · add(OrganisationFolder parentOrg, String resourceName, String text) · add(Path path, String id, String text) · addSeperator(String id) · getRootFolder() · getUser() · getOrgRoles() · hasAnyOrgRole(Collection<String> roleNames) · hasOrgRole(String s) · getItem(String id) · getConfigItem() · setConfigItem(MenuConfigItem configItem) · getMenuApplications()

getActiveItems()

Returns: MenuItemList

Builds a new list containing only this item's children that are currently active, as reported by isActive.

getId()

Returns: String

The id contributors see. Normally the item's own id, but while a section is being offered under one of the ids it replaced this returns that legacy id, so code dispatching on it continues to work.

getCanonicalId()

Returns: String

The item's real id, unaffected by presentAs. Use this whenever the answer must not depend on which identity a section is currently wearing, for example looking the item up in the section registry or keying anything persistent off it.

presentAs(String aliasId, Runnable work)

Returns: void

Runs something with this item temporarily answering to a different id. Admin menu sections absorb the roots they replace, but the 40-odd Java menu contributors dispatch on the parent id they are handed, such as a switch case matching "menuGroupsUsers", and so on. Rather than rewrite every one of them, the section is offered to contributors once per identity it answers to, so their existing code adds children to the section without knowing it moved. See MenuManager's appendMenu method. The identity is only worn for the duration of the callback, and is always restored afterwards.

ParameterDescription
aliasIdthe id to answer to for the duration of the callback. Must not be null
workwhat to run while wearing that identity. Must not be null

getText()

Returns: String

The label rendered for this menu item.

setText(String text)

Returns: void

Sets the label rendered for this menu item.

ParameterDescription
textthe display text to set. May be null

text(String s)

Returns: MenuItem

Sets the display text and returns this item, for chaining while building a menu.

ParameterDescription
sthe display text to set. May be null

getOrdering()

Returns: int

Where this item sorts among its siblings. Lower values sort first; the default is 100.

setOrdering(int ordering)

Returns: void

Sets where this item sorts among its siblings.

ParameterDescription
orderingthe sort order to use, lower values sort first

getHref()

Returns: String

The link this menu item points to.

setHref(String href)

Returns: void

Sets the link this menu item points to.

ParameterDescription
hrefthe href to set. May be null or blank for a grouping item

getKeywords()

Returns: Set<String>

Extra terms the menu's filter box matches this item on, beyond its own label. A hub page is the case this exists for: "Databases and storage" is where JSON Data went, so someone typing "json" has to land on it, and the label cannot say every name it absorbed. Keywords are held lowercase, since the filter lowercases what is typed. There are two additive sources: an app declares its own on the menu element in controllers.xml, and the platform holds them per id in AdminMenuSections, which is what reaches items an app version predating the restructure declared, as well as Java declared items.

getKeywordsCsv()

Returns: String

The item's keywords as a comma separated list, for rendering into the menu markup.

addKeywords(Collection<String> toAdd)

Returns: void

Adds terms to match on, ignoring blanks and duplicates. Additive: callers contribute, none replaces.

ParameterDescription
toAddterms to add. May be null or empty

addKeywords(String csv)

Returns: void

Adds terms to match on from a comma separated list, as an app declares them in controllers.xml.

ParameterDescription
csvcomma separated terms. May be null or blank

getCssClass()

Returns: String

The CSS classes rendered on this menu item, normally used to select its icon.

setCssClass(String cssClass)

Returns: void

Sets the CSS classes rendered on this menu item.

ParameterDescription
cssClassthe css classes to set. May be null

isHidden()

Returns: boolean

Whether this item is excluded from the visible menu.

setHidden(boolean hidden)

Returns: void

Sets whether this item is excluded from the visible menu.

ParameterDescription
hiddentrue to hide the item

isActive()

Returns: boolean

Applications indicate the current active id by calling MenuItem.setActiveId when the resource is located. A section is also active when a page has declared itself active under one of the ids that section replaced, since most pages still name the old root.

getItems()

Returns: MenuItemList

This item's children, building them on first access by asking the MenuManager to append this item's menu contributions. Subsequent calls return the same, already built list.

getVisible()

Returns: List<MenuItem>

This item's children that are not hidden, computed once and cached. Any exception raised while building the list is logged and swallowed, yielding an empty list rather than failing the page render.

peekItems()

Returns: MenuItemList

Return the sub items if they have been loaded already, or null

add(String id)

Returns: MenuItem

Creates a new child item with the given id and adds it to this item's children.

ParameterDescription
idthe id of the new child item

getOriginIdentity()

Returns: String

The id of the parent that the contributing code was addressing when it added this item. For a section built out of several old roots this records which one the item came from, which is what lets the section group its items by origin instead of interleaving them. Normally the parent's own id, but a legacy id when the item was added during one of the parent's legacy identity passes.

setOriginIdentity(String originIdentity)

Returns: void

Overrides the recorded origin. Needed when an old top level page is kept as a child of the section that absorbed it: the item is created during the root pass, so it would otherwise be recorded against the root rather than against the id it used to be.

ParameterDescription
originIdentitythe identity to record. May be null

getOrCreate(String id, String text)

Returns: MenuItem

Finds the existing child with the given id, or creates a grouping child with no href.

ParameterDescription
idthe id to find or create
textthe display text to use if a new item is created

getOrCreate(String id, String text, Path p)

Returns: MenuItem

Finds the existing child with the given id, or creates one linking to the given path.

ParameterDescription
idthe id to find or create
textthe display text to use if a new item is created
pthe path to use as the item's href if a new item is created

getOrCreate(String id, String text, String href)

Returns: MenuItem

Finds the existing child with the given id, or creates one with the given href. If this item is the admin root and the id names an old top level item that has been absorbed into a named admin menu section, the request is redirected into that section instead of creating another top level item.

ParameterDescription
idthe id to find or create
textthe display text to use if a new item is created
hrefthe href to use if a new item is created. May be null or blank for a grouping item

getOrCreate(String id, String text, String href, String css)

Returns: MenuItem

Finds the existing child with the given id, or creates one with the given href and CSS icon class. If this item is the admin root and the id names an old top level item that has been absorbed into a named admin menu section, the request is redirected into that section instead of creating another top level item.

ParameterDescription
idthe id to find or create
textthe display text to use if a new item is created
hrefthe href to use if a new item is created. May be null or blank for a grouping item
cssthe css icon class to use if a new item is created. May be null

add(OrganisationFolder parentOrg, String resourceName, String text)

Returns: MenuItem

Adds a child item linking to a named resource under the given organisation folder, using the resource name prefixed with "menu" as the child's id.

ParameterDescription
parentOrgthe organisation folder the linked resource lives under
resourceNamethe name of the resource within the organisation folder, used to build both the id and the href
textthe display text for the new item

add(Path path, String id, String text)

Returns: MenuItem

Adds a child item with the given id, linking to the given path.

ParameterDescription
paththe path to use as the new item's href
idthe id of the new child item
textthe display text for the new item

addSeperator(String id)

Returns: MenuItem

Adds a child item with the given id and no text or href, used to render a visual separator in the menu.

ParameterDescription
idthe id of the separator item

getRootFolder()

Returns: RootFolder

The root folder of the current request, used when deciding whether admin menu sections apply.

getUser()

Returns: Profile

The currently signed in profile, as seen by KademiSecurityManager.

getOrgRoles()

Returns: Set<Role>

The roles the current user holds within the organisation this menu was built for.

hasAnyOrgRole(Collection<String> roleNames)

Returns: boolean

Tests whether the current user holds any of the given organisation roles.

ParameterDescription
roleNamesthe role names to test for

hasOrgRole(String s)

Returns: boolean

Tests whether the current user holds the given organisation role.

ParameterDescription
sthe role name to test for

getItem(String id)

Returns: MenuItem

Finds a child of this item by id, without building the children if they have not been loaded yet.

ParameterDescription
idthe id of the child to find

getConfigItem()

Returns: MenuConfigItem

The account level menu configuration entry associated with this item, if any.

setConfigItem(MenuConfigItem configItem)

Returns: void

Associates this item with an account level menu configuration entry.

ParameterDescription
configItemthe config item to associate. May be null

getMenuApplications()

Returns: List<MenuApplication>

The active menu applications that were resolved when the menu tree this item belongs to was built.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.