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
Nested ClassesModifier and TypeClassDescriptionstatic enumPossible 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.ElementOrBuilderNested 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
FieldsModifier and TypeFieldDescriptionstatic final StringIf this attribute exists its value must be aViewElementorViewElementBuilder.static final StringIf set totrueand the item has anATTR_ICONattribute set, only the icon element will be rendered if the menu item is at the top level.static final StringCan be set to a value ofNavComponentBuilder.Separator.static final StringHolds the customViewElementorViewElementBuilderthat should be used to render the list item for thatMenu.static final StringIf set totruethis group will always be rendered as a group (dropdown) even if there is only a single item.static final StringIf set totruethe label for the group will never be replaced by the label of the selected item.static final StringHolds the customViewElementorViewElementBuilderthat should be used to render the link inside the list item of thatMenu.static final StringHolds aViewElement.WitherSetterthat should be applied to the view element of an item.static final StringIf a customViewElementBuilderis being used for rendering (part of) aMenu, theViewElementBuilderContextwill contain theMenubeing rendered as an attribute with this name.Fields inherited from class com.foreach.across.modules.web.ui.ViewElementBuilderSupport
customTemplate, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddHtmlAttributes(com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement node, Map<String, Object> attributes) Deprecated.protected voidaddIconAndText(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 LinkViewElementaddItemLink(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 booleanaddViewElementIfAttributeExists(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.NodeViewElementbuildMenu(com.foreach.across.modules.web.menu.Menu menu, com.foreach.across.modules.web.ui.ViewElementBuilderContext builderContext) protected com.foreach.across.modules.web.ui.elements.NodeViewElementcreateElement(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_WITHERattribute on aMenuitem by combining the collection of setters into a singleViewElement.WitherSetterto 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_WITHERattribute on aMenuitem by combining the collection of setters into a singleViewElement.WitherSetterto 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.MenufindFirstIncludedChild(com.foreach.across.modules.web.menu.Menu menu) protected com.foreach.across.modules.web.menu.MenufindItemToRender(com.foreach.across.modules.web.menu.Menu item) protected com.foreach.across.modules.web.menu.MenugetFirstNonGroupSelectedItem(com.foreach.across.modules.web.menu.Menu menu) static StringhtmlAttribute(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-pathattribute 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_GROUPset.menu(com.foreach.across.modules.web.menu.Menu menu) Set the fixed menu to render.Set the name of the menu to render.protected intnumberOfChildrenToInclude(com.foreach.across.modules.web.menu.Menu menu) protected booleanshouldIncludeItem(com.foreach.across.modules.web.menu.Menu item) protected booleanshouldKeepAsGroup(com.foreach.across.modules.web.menu.Menu item) protected com.foreach.across.modules.web.ui.ViewElement.WitherSetterwitherAttribute(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, linkBuilderMethods inherited from class com.foreach.across.modules.bootstrapui.elements.builder.AbstractHtmlSupportingNodeViewElementBuilder
escapeHtml, isEscapeHtml, resolveTextElement, toTextElementMethods inherited from class com.foreach.across.modules.web.ui.elements.builder.AbstractNodeViewElementBuilder
apply, attribute, attributes, clearAttributes, css, htmlId, removeAttribute, removeCssMethods inherited from class com.foreach.across.modules.web.ui.elements.builder.ContainerViewElementBuilderSupport
add, add, addAll, addFirst, addFirst, sortMethods inherited from class com.foreach.across.modules.web.ui.ViewElementBuilderSupport
build, configure, customTemplate, elementSupplier, elementSupplier, name, postProcess, postProcessor, registerWebResources, withMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.foreach.across.modules.web.ui.elements.builder.HtmlViewElementBuilder
data, removeDataMethods 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 aViewElementorViewElementBuilder. If so the resultingViewElementwill be added before the item text.- See Also:
-
ATTR_ICON_ONLY
If set totrueand the item has anATTR_ICONattribute 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 customViewElementorViewElementBuilderthat 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 customViewElementorViewElementBuilderthat 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.WitherSetterthat 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 totruethis 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 totruethe label for the group will never be replaced by the label of the selected item. This attribute is only relevant if the builder is @DefaultNavComponentBuilderconfigured 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 customViewElementBuilderis being used for rendering (part of) aMenu, theViewElementBuilderContextwill contain theMenubeing 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-pathattribute 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_GROUPset. 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:
createElementin 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 aMenuattribute 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_WITHERattribute on aMenuitem by combining the collection of setters into a singleViewElement.WitherSetterto 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_WITHERattribute on aMenuitem by combining the collection of setters into a singleViewElement.WitherSetterto be applied to the generated view element for the menu item. Depending on thereplacePreviousRulesargument, 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