Class BootstrapElementUtils
java.lang.Object
com.foreach.across.modules.bootstrapui.utils.BootstrapElementUtils
Contains several static utility methods for working with elements.
- Author:
- Arne Vandamme
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic FormControlElement
getFormControl
(com.foreach.across.modules.web.ui.ViewElement viewElement) Will search for the firstFormControlElement
instance that is not anInputGroupFormElement
.static <V extends FormControlElement>
VgetFormControl
(com.foreach.across.modules.web.ui.ViewElement viewElement, Class<V> expectedType) Will search for the firstFormControlElement
instance that matches the expected type.static <T extends com.foreach.across.modules.web.ui.ViewElement>
ControlNamePrefixAdjuster<T>prefixControlNames
(@NonNull String prefix) CreateControlNamePrefixAdjuster
preconfigured to prefix all control names with the given prefix, ignoring any first underscore character, adding dot separators and recursing through all children in case the control is a container.static void
prefixControlNames
(@NonNull String prefix, @NonNull com.foreach.across.modules.web.ui.elements.ContainerViewElement container) Prefix all controls in a container.static <T extends com.foreach.across.modules.web.ui.ViewElement>
ControlNamePrefixAdjuster<T>replaceControlNamesPrefix
(@NonNull String prefixToReplace, @NonNull String newPrefix) CreateControlNamePrefixAdjuster
preconfigured to update all control names that match the initial prefix, and replace said prefix with the new value.static void
replaceControlNamesPrefix
(@NonNull String prefixToReplace, @NonNull String newPrefix, @NonNull com.foreach.across.modules.web.ui.elements.ContainerViewElement container) Updates any control having a control name starting with a given prefix.
-
Constructor Details
-
BootstrapElementUtils
protected BootstrapElementUtils()
-
-
Method Details
-
getFormControl
public static FormControlElement getFormControl(com.foreach.across.modules.web.ui.ViewElement viewElement) Will search for the firstFormControlElement
instance that is not anInputGroupFormElement
. It is possible that the instance itself is returned. This method will recurse throughContainerViewElement
types until an instance is returned.- Parameters:
viewElement
- instance- Returns:
- form control instance, or
null
if not found
-
getFormControl
public static <V extends FormControlElement> V getFormControl(com.foreach.across.modules.web.ui.ViewElement viewElement, Class<V> expectedType) Will search for the firstFormControlElement
instance that matches the expected type. It is possible that the instance itself is returned. This method will recurse throughContainerViewElement
types until an instance is returned.- Parameters:
viewElement
- instanceexpectedType
- the control should have- Returns:
- form control instance, or
null
if not found
-
prefixControlNames
public static void prefixControlNames(@NonNull @NonNull String prefix, @NonNull @NonNull com.foreach.across.modules.web.ui.elements.ContainerViewElement container) Prefix all controls in a container. This is utility method that will scan for all uniqueFormInputElement
controls and ensure they are prefixed only once. When it encounters aFormControlElement.Proxy
it will also exclude the targetViewElement
from control name updating. This method will insert a . between the prefix and the original control name, unless the control name starts with a special character. SeeprefixControlNames(String)
andControlNamePrefixAdjuster
if you want to customize.- Parameters:
prefix
- to apply to any input elementcontainer
- in which to find all input elements- See Also:
-
replaceControlNamesPrefix
public static void replaceControlNamesPrefix(@NonNull @NonNull String prefixToReplace, @NonNull @NonNull String newPrefix, @NonNull @NonNull com.foreach.across.modules.web.ui.elements.ContainerViewElement container) Updates any control having a control name starting with a given prefix. Said prefix will be replaced by the new one. LikeprefixControlNames(String, ContainerViewElement)
this method should handle different form control elements correctly. SeereplaceControlNamesPrefix(String, String)
andControlNamePrefixAdjuster
if you want to customize.- Parameters:
prefixToReplace
- prefix that should be replacednewPrefix
- prefix that should be used insteadcontainer
- in which to find all input elements- See Also:
-
prefixControlNames
public static <T extends com.foreach.across.modules.web.ui.ViewElement> ControlNamePrefixAdjuster<T> prefixControlNames(@NonNull @NonNull String prefix) CreateControlNamePrefixAdjuster
preconfigured to prefix all control names with the given prefix, ignoring any first underscore character, adding dot separators and recursing through all children in case the control is a container. The return value is both aConsumer
andViewElementPostProcessor
.- Parameters:
prefix
- to add- Returns:
- adjuster instance
-
replaceControlNamesPrefix
public static <T extends com.foreach.across.modules.web.ui.ViewElement> ControlNamePrefixAdjuster<T> replaceControlNamesPrefix(@NonNull @NonNull String prefixToReplace, @NonNull @NonNull String newPrefix) CreateControlNamePrefixAdjuster
preconfigured to update all control names that match the initial prefix, and replace said prefix with the new value. LikeprefixControlNames(String)
the return value is preconfigured to recurse through container members, ignore underscores and add dot separators where necessary. The return value is both aConsumer
andViewElementPostProcessor
.- Parameters:
prefixToReplace
- prefix that should be replacednewPrefix
- prefix that should be used instead- Returns:
- adjuster instance
-