Class NavComponentBuilder<SELF extends NavComponentBuilder<SELF>>
java.lang.Object
com.foreach.across.modules.web.ui.ViewElementBuilderSupport<T,SELF>
com.foreach.across.modules.web.ui.elements.builder.ContainerViewElementBuilderSupport<T,SELF>
com.foreach.across.modules.web.ui.elements.builder.AbstractNodeViewElementBuilder<T,SELF>
com.foreach.across.modules.bootstrapui.elements.builder.AbstractHtmlSupportingNodeViewElementBuilder<T,SELF>
com.foreach.across.modules.bootstrapui.elements.builder.AbstractLinkSupportingNodeViewElementBuilder<com.foreach.across.modules.web.ui.elements.NodeViewElement,SELF>
com.foreach.across.modules.bootstrapui.components.builder.NavComponentBuilder<SELF>
- All Implemented Interfaces:
com.foreach.across.modules.web.ui.elements.builder.HtmlViewElementBuilder<com.foreach.across.modules.web.ui.elements.NodeViewElement,
,SELF> com.foreach.across.modules.web.ui.ViewElementBuilder<com.foreach.across.modules.web.ui.elements.NodeViewElement>
- Direct Known Subclasses:
BreadcrumbNavComponentBuilder
,DefaultNavComponentBuilder
,PanelsNavComponentBuilder
public abstract class NavComponentBuilder<SELF extends NavComponentBuilder<SELF>>
extends AbstractLinkSupportingNodeViewElementBuilder<com.foreach.across.modules.web.ui.elements.NodeViewElement,SELF>
Abstract base class for rendering
Menu
items to nav-like structures.- Since:
- 1.0.0
- Author:
- Arne Vandamme
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Possible values for attributeATTR_INSERT_SEPARATOR
.Nested classes/interfaces inherited from class com.foreach.across.modules.web.ui.ViewElementBuilderSupport
com.foreach.across.modules.web.ui.ViewElementBuilderSupport.ElementOrBuilder
Nested classes/interfaces inherited from interface com.foreach.across.modules.web.ui.ViewElementBuilder
com.foreach.across.modules.web.ui.ViewElementBuilder.Wither<T extends com.foreach.across.modules.web.ui.ViewElementBuilder>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
If this attribute exists its value must be aViewElement
orViewElementBuilder
.static final String
If set totrue
and the item has anATTR_ICON
attribute set, only the icon element will be rendered if the menu item is at the top level.static final String
Can be set to a value ofNavComponentBuilder.Separator
.static final String
Holds the customViewElement
orViewElementBuilder
that should be used to render the list item for thatMenu
.static final String
If set totrue
this group will always be rendered as a group (dropdown) even if there is only a single item.static final String
If set totrue
the label for the group will never be replaced by the label of the selected item.static final String
Holds the customViewElement
orViewElementBuilder
that should be used to render the link inside the list item of thatMenu
.static final String
Holds aViewElement.WitherSetter
that should be applied to the view element of an item.static final String
If a customViewElementBuilder
is being used for rendering (part of) aMenu
, theViewElementBuilderContext
will contain theMenu
being rendered as an attribute with this name.Fields inherited from class com.foreach.across.modules.web.ui.ViewElementBuilderSupport
customTemplate, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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) customizeViewElement
(boolean replacePreviousRules, com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters) Create a registrar for theATTR_VIEW_ELEMENT_WITHER
attribute on aMenu
item by combining the collection of setters into a singleViewElement.WitherSetter
to be applied to the generated view element for the menu item.customizeViewElement
(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters) Create a registrar for theATTR_VIEW_ELEMENT_WITHER
attribute on aMenu
item by combining the collection of setters into a singleViewElement.WitherSetter
to be applied to the generated view element for the menu item.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) includePathAsDataAttribute
(boolean shouldInclude) Should theMenu.getPath()
be included asdata-ax-menu-path
attribute on the list item.keepGroupsAsGroup
(boolean keepGroupsAsGroup) Set to true if the behaviour for groups should be to keep them as group unless they have aATTR_KEEP_AS_GROUP
set.menu
(com.foreach.across.modules.web.menu.Menu menu) Set the fixed menu to render.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) Methods inherited from class com.foreach.across.modules.bootstrapui.elements.builder.AbstractLinkSupportingNodeViewElementBuilder
buildLink, linkBuilder
Methods inherited from class com.foreach.across.modules.bootstrapui.elements.builder.AbstractHtmlSupportingNodeViewElementBuilder
escapeHtml, isEscapeHtml, resolveTextElement, toTextElement
Methods inherited from class com.foreach.across.modules.web.ui.elements.builder.AbstractNodeViewElementBuilder
apply, attribute, attributes, clearAttributes, css, htmlId, removeAttribute, removeCss
Methods inherited from class com.foreach.across.modules.web.ui.elements.builder.ContainerViewElementBuilderSupport
add, add, addAll, addFirst, addFirst, sort
Methods inherited from class com.foreach.across.modules.web.ui.ViewElementBuilderSupport
build, configure, customTemplate, elementSupplier, elementSupplier, name, postProcess, postProcessor, registerWebResources, with
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.foreach.across.modules.web.ui.elements.builder.HtmlViewElementBuilder
data, removeData
Methods inherited from interface com.foreach.across.modules.web.ui.ViewElementBuilder
andThen, build, doWith, map, map, postProcess, postProcess
-
Field Details
-
ATTR_ICON
If this attribute exists its value must be aViewElement
orViewElementBuilder
. If so the resultingViewElement
will be added before the item text.- See Also:
-
ATTR_ICON_ONLY
If set totrue
and the item has anATTR_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.- See Also:
-
ATTR_ITEM_VIEW_ELEMENT
Holds the customViewElement
orViewElementBuilder
that should be used to render the list item for thatMenu
. The custom element should take care of all possible child menu items.- See Also:
-
ATTR_LINK_VIEW_ELEMENT
Holds the customViewElement
orViewElementBuilder
that should be used to render the link inside the list item of thatMenu
. In case of a group item, the custom element should handle toggling the dropdown.- See Also:
-
ATTR_VIEW_ELEMENT_WITHER
Holds aViewElement.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.- See Also:
-
ATTR_KEEP_AS_GROUP
If set totrue
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.- See Also:
-
ATTR_KEEP_GROUP_ITEM
If set totrue
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 withDefaultNavComponentBuilder.replaceGroupBySelectedItem()
.- See Also:
-
ATTR_INSERT_SEPARATOR
Can be set to a value ofNavComponentBuilder.Separator
. Determines where a separator should be added if the item is rendered in a dropdown.- See Also:
-
CTX_CURRENT_MENU_ITEM
If a customViewElementBuilder
is being used for rendering (part of) aMenu
, theViewElementBuilderContext
will contain theMenu
being rendered as an attribute with this name.- See Also:
-
-
Constructor Details
-
NavComponentBuilder
public NavComponentBuilder()
-
-
Method Details
-
includePathAsDataAttribute
Should theMenu.getPath()
be included asdata-ax-menu-path
attribute on the list item.- Parameters:
shouldInclude
- true if data attribute should be set- Returns:
- current builder
-
filter
Set a predicate that menu items should match before they will be rendered. By default all menu items will match.- Parameters:
predicate
- to match- Returns:
- current builder
-
keepGroupsAsGroup
Set to true if the behaviour for groups should be to keep them as group unless they have aATTR_KEEP_AS_GROUP
set. Default is not to keep them as group but to replace them by the item if there is only one.- Returns:
- current builder
-
createElement
protected com.foreach.across.modules.web.ui.elements.NodeViewElement createElement(com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) - Specified by:
createElement
in classcom.foreach.across.modules.web.ui.ViewElementBuilderSupport<com.foreach.across.modules.web.ui.elements.NodeViewElement,
SELF extends NavComponentBuilder<SELF>>
-
addHtmlAttributes
@Deprecated protected void addHtmlAttributes(com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement node, Map<String, Object> attributes) Deprecated. -
htmlAttribute
Deprecated.Turns this regular attribute name into a HTML attribute name for aMenu
attribute by adding the right prefix.- Parameters:
attributeName
- to convert- Returns:
- attribute name for HTML attribute
-
customizeViewElement
public static Consumer<Map<String,Object>> customizeViewElement(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters) Create a registrar for theATTR_VIEW_ELEMENT_WITHER
attribute on aMenu
item by combining the collection of setters into a singleViewElement.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, usecustomizeViewElement(boolean, ViewElement.WitherSetter[])
.- Parameters:
setters
- to add when processing the view element- Returns:
- attribute registrar
-
customizeViewElement
public static Consumer<Map<String,Object>> customizeViewElement(boolean replacePreviousRules, com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters) Create a registrar for theATTR_VIEW_ELEMENT_WITHER
attribute on aMenu
item by combining the collection of setters into a singleViewElement.WitherSetter
to be applied to the generated view element for the menu item. Depending on thereplacePreviousRules
argument, the setters will be appended to or replace a previously configured value.- Parameters:
replacePreviousRules
- true if any previous value should be ignoredsetters
- to add when processing the view element- Returns:
- attribute registrar