public abstract class NavComponentBuilder<SELF extends NavComponentBuilder<SELF>> extends AbstractLinkSupportingNodeViewElementBuilder<com.foreach.across.modules.web.ui.elements.NodeViewElement,SELF>
Menu
items to nav-like structures.DefaultNavComponentBuilder
,
PanelsNavComponentBuilder
,
BreadcrumbNavComponentBuilder
Modifier and Type | Class and Description |
---|---|
static class |
NavComponentBuilder.Separator
Possible values for attribute
ATTR_INSERT_SEPARATOR . |
Modifier and Type | Field and Description |
---|---|
static String |
ATTR_ICON
If this attribute exists its value must be a
ViewElement
or ViewElementBuilder . |
static String |
ATTR_ICON_ONLY
If set to
true and the item has an ATTR_ICON attribute set, only the icon element
will be rendered if the menu item is at the top level. |
static String |
ATTR_INSERT_SEPARATOR
Can be set to a value of
NavComponentBuilder.Separator . |
static String |
ATTR_ITEM_VIEW_ELEMENT
Holds the custom
ViewElement or ViewElementBuilder that should be used to render
the list item for that Menu . |
static String |
ATTR_KEEP_AS_GROUP
If set to
true this group will always be rendered as a group (dropdown) even if there is only
a single item. |
static String |
ATTR_KEEP_GROUP_ITEM
If set to
true the label for the group will never be replaced by the label of the selected item. |
static String |
ATTR_LINK_VIEW_ELEMENT
Holds the custom
ViewElement or ViewElementBuilder that should be used to render the link
inside the list item of that Menu . |
static String |
CTX_CURRENT_MENU_ITEM
If a custom
ViewElementBuilder is being used for rendering (part of) a Menu , the
ViewElementBuilderContext will contain the Menu being rendered as an attribute with this name. |
Constructor and Description |
---|
NavComponentBuilder() |
Modifier and Type | Method and Description |
---|---|
protected void |
addHtmlAttributes(com.foreach.across.modules.web.ui.elements.NodeViewElement node,
Map<String,Object> attributes) |
protected void |
addIconAndText(com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement node,
com.foreach.across.modules.web.menu.Menu item,
String resolvedTitle,
boolean iconAllowed,
boolean iconOnly,
com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) |
protected LinkViewElement |
addItemLink(com.foreach.across.modules.web.ui.elements.NodeViewElement container,
com.foreach.across.modules.web.menu.Menu item,
boolean iconAllowed,
boolean iconOnly,
com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) |
protected boolean |
addViewElementIfAttributeExists(com.foreach.across.modules.web.menu.Menu item,
String attributeName,
com.foreach.across.modules.web.ui.elements.ContainerViewElement container,
com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) |
protected abstract com.foreach.across.modules.web.ui.elements.NodeViewElement |
buildMenu(com.foreach.across.modules.web.menu.Menu menu,
com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) |
protected com.foreach.across.modules.web.ui.elements.NodeViewElement |
createElement(com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) |
SELF |
filter(java.util.function.Predicate<com.foreach.across.modules.web.menu.Menu> predicate)
Set a predicate that menu items should match before they will be rendered.
|
protected com.foreach.across.modules.web.menu.Menu |
findFirstIncludedChild(com.foreach.across.modules.web.menu.Menu menu) |
protected com.foreach.across.modules.web.menu.Menu |
findItemToRender(com.foreach.across.modules.web.menu.Menu item) |
protected com.foreach.across.modules.web.menu.Menu |
getFirstNonGroupSelectedItem(com.foreach.across.modules.web.menu.Menu menu) |
static String |
htmlAttribute(String attributeName)
Turns this regular attribute name into a HTML attribute name for a
Menu attribute
by adding the right prefix. |
protected java.util.stream.Stream<com.foreach.across.modules.web.menu.Menu> |
includedItems(com.foreach.across.modules.web.menu.Menu menu) |
SELF |
keepGroupsAsGroup(boolean keepGroupsAsGroup)
Set to true if the behaviour for groups should be to keep them as group unless they have a
ATTR_KEEP_AS_GROUP set. |
SELF |
menu(com.foreach.across.modules.web.menu.Menu menu)
Set the fixed menu to render.
|
SELF |
menu(String menuName)
Set the name of the menu to render.
|
protected int |
numberOfChildrenToInclude(com.foreach.across.modules.web.menu.Menu menu) |
protected boolean |
shouldIncludeItem(com.foreach.across.modules.web.menu.Menu item) |
protected boolean |
shouldKeepAsGroup(com.foreach.across.modules.web.menu.Menu item) |
buildLink, linkBuilder
escapeHtml, isEscapeHtml, resolveTextElement, toTextElement
apply, attribute, attributes, clearAttributes, css, htmlId, removeAttribute, removeCss
add, add, addAll, addFirst, addFirst, sort
build, configure, customTemplate, name, postProcess, postProcessor, registerWebResources
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static final String ATTR_ICON
ViewElement
or ViewElementBuilder
. If so the resulting ViewElement
will be added before the item text.public static final String ATTR_ICON_ONLY
true
and the item has an ATTR_ICON
attribute set, only the icon element
will be rendered if the menu item is at the top level. This attribute will be inherited from the group.
Note that the actual title will still be added wrapped in a span with class nav-item-title.
This supports for example collapsing navbars where the title should be visible anyway.public static final String ATTR_ITEM_VIEW_ELEMENT
ViewElement
or ViewElementBuilder
that should be used to render
the list item for that Menu
. The custom element should take care of all possible child menu items.public static final String ATTR_LINK_VIEW_ELEMENT
ViewElement
or ViewElementBuilder
that should be used to render the link
inside the list item of that Menu
. In case of a group item, the custom element should handle
toggling the dropdown.public static final String ATTR_KEEP_AS_GROUP
true
this group will always be rendered as a group (dropdown) even if there is only
a single item. The default behaviour would be to then just render that item.public static final String ATTR_KEEP_GROUP_ITEM
true
the label for the group will never be replaced by the label of the selected item.
This attribute is only relevant if the builder is @ DefaultNavComponentBuilder
configured with
DefaultNavComponentBuilder.replaceGroupBySelectedItem()
.public static final String ATTR_INSERT_SEPARATOR
NavComponentBuilder.Separator
. Determines where a separator should be added if the item is
rendered in a dropdown.public static final String CTX_CURRENT_MENU_ITEM
ViewElementBuilder
is being used for rendering (part of) a Menu
, the
ViewElementBuilderContext
will contain the Menu
being rendered as an attribute with this name.public SELF menu(String menuName)
Menu
should be available as an
attribute with that name on the ViewElementBuilderContext
.
NOTE: this value will be ignored if menu(Menu)
was set.menuName
- name of the menu attributepublic SELF menu(com.foreach.across.modules.web.menu.Menu menu)
menu
- to renderpublic SELF filter(@NonNull java.util.function.Predicate<com.foreach.across.modules.web.menu.Menu> predicate)
predicate
- to matchpublic SELF keepGroupsAsGroup(boolean keepGroupsAsGroup)
ATTR_KEEP_AS_GROUP
set.
Default is not to keep them as group but to replace them by the item if there is only one.protected com.foreach.across.modules.web.ui.elements.NodeViewElement createElement(com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext)
createElement
in class com.foreach.across.modules.web.ui.ViewElementBuilderSupport<com.foreach.across.modules.web.ui.elements.NodeViewElement,SELF extends NavComponentBuilder<SELF>>
protected abstract com.foreach.across.modules.web.ui.elements.NodeViewElement buildMenu(com.foreach.across.modules.web.menu.Menu menu, com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext)
protected java.util.stream.Stream<com.foreach.across.modules.web.menu.Menu> includedItems(com.foreach.across.modules.web.menu.Menu menu)
protected boolean shouldIncludeItem(com.foreach.across.modules.web.menu.Menu item)
protected com.foreach.across.modules.web.menu.Menu findItemToRender(com.foreach.across.modules.web.menu.Menu item)
protected com.foreach.across.modules.web.menu.Menu findFirstIncludedChild(com.foreach.across.modules.web.menu.Menu menu)
protected void addHtmlAttributes(com.foreach.across.modules.web.ui.elements.NodeViewElement node, Map<String,Object> attributes)
protected boolean shouldKeepAsGroup(com.foreach.across.modules.web.menu.Menu item)
protected com.foreach.across.modules.web.menu.Menu getFirstNonGroupSelectedItem(com.foreach.across.modules.web.menu.Menu menu)
protected LinkViewElement addItemLink(com.foreach.across.modules.web.ui.elements.NodeViewElement container, com.foreach.across.modules.web.menu.Menu item, boolean iconAllowed, boolean iconOnly, com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext)
protected void addIconAndText(com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement node, com.foreach.across.modules.web.menu.Menu item, String resolvedTitle, boolean iconAllowed, boolean iconOnly, com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext)
protected boolean addViewElementIfAttributeExists(com.foreach.across.modules.web.menu.Menu item, String attributeName, com.foreach.across.modules.web.ui.elements.ContainerViewElement container, com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext)
protected int numberOfChildrenToInclude(com.foreach.across.modules.web.menu.Menu menu)
Copyright © 2019. All rights reserved.