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 |
ATTR_VIEW_ELEMENT_WITHER
Holds a
ViewElement.WitherSetter that should be applied to the
view element of an item. |
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.AbstractNodeViewElement node,
Map<String,Object> attributes)
Deprecated.
|
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) |
static Consumer<Map<String,Object>> |
customizeViewElement(boolean replacePreviousRules,
com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
Create a registrar for the
ATTR_VIEW_ELEMENT_WITHER attribute on a Menu item by combining the collection of setters into a single
ViewElement.WitherSetter to be applied to the generated view element for the menu item. |
static Consumer<Map<String,Object>> |
customizeViewElement(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
Create a registrar for the
ATTR_VIEW_ELEMENT_WITHER attribute on a Menu item by combining the collection of setters into a single
ViewElement.WitherSetter to be applied to the generated view element for the menu item. |
SELF |
filter(@NonNull 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)
Deprecated.
|
protected com.foreach.across.modules.web.ui.ViewElement.WitherSetter<com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement> |
htmlAttributesOf(com.foreach.across.modules.web.menu.Menu item)
Deprecated.
|
protected Stream<com.foreach.across.modules.web.menu.Menu> |
includedItems(com.foreach.across.modules.web.menu.Menu menu) |
SELF |
includePathAsDataAttribute(boolean shouldInclude)
Should the
Menu.getPath() be included as data-ax-menu-path attribute on the list item. |
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) |
protected com.foreach.across.modules.web.ui.ViewElement.WitherSetter |
witherAttribute(com.foreach.across.modules.web.menu.Menu itemToRender,
com.foreach.across.modules.web.menu.Menu originalItem) |
buildLink, linkBuilderescapeHtml, isEscapeHtml, resolveTextElement, toTextElementapply, attribute, attributes, clearAttributes, css, htmlId, removeAttribute, removeCssadd, add, addAll, addFirst, addFirst, sortbuild, configure, customTemplate, elementSupplier, elementSupplier, name, postProcess, postProcessor, registerWebResources, withclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpublic 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_VIEW_ELEMENT_WITHER
ViewElement.WitherSetter that should be applied to the
view element of an item. Which element will be the target depends on the component builder and item.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 includePathAsDataAttribute(boolean shouldInclude)
Menu.getPath() be included as data-ax-menu-path attribute on the list item.shouldInclude - true if data attribute should be setpublic SELF filter(@NonNull @NonNull 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 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)
@Deprecated protected com.foreach.across.modules.web.ui.ViewElement.WitherSetter<com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement> htmlAttributesOf(com.foreach.across.modules.web.menu.Menu item)
@Deprecated protected void addHtmlAttributes(com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement 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)
protected com.foreach.across.modules.web.ui.ViewElement.WitherSetter witherAttribute(com.foreach.across.modules.web.menu.Menu itemToRender,
com.foreach.across.modules.web.menu.Menu originalItem)
@Deprecated public static String htmlAttribute(String attributeName)
Menu attribute
by adding the right prefix.attributeName - to convertpublic static Consumer<Map<String,Object>> customizeViewElement(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
ATTR_VIEW_ELEMENT_WITHER attribute on a Menu item by combining the collection of setters into a single
ViewElement.WitherSetter to be applied to the generated view element for the menu item.
A previously configured value will be kept and the new setters will be executed after. If you want to replace any previously configured
setters, use customizeViewElement(boolean, ViewElement.WitherSetter[]).setters - to add when processing the view elementpublic static Consumer<Map<String,Object>> customizeViewElement(boolean replacePreviousRules, com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
ATTR_VIEW_ELEMENT_WITHER attribute on a Menu item by combining the collection of setters into a single
ViewElement.WitherSetter to be applied to the generated view element for the menu item.
Depending on the replacePreviousRules argument, the setters will be appended to or replace a previously configured value.replacePreviousRules - true if any previous value should be ignoredsetters - to add when processing the view elementCopyright © 2020. All rights reserved.