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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FormControlElementgetFormControl(com.foreach.across.modules.web.ui.ViewElement viewElement) Will search for the firstFormControlElementinstance that is not anInputGroupFormElement.static <V extends FormControlElement>
VgetFormControl(com.foreach.across.modules.web.ui.ViewElement viewElement, Class<V> expectedType) Will search for the firstFormControlElementinstance that matches the expected type.static <T extends com.foreach.across.modules.web.ui.ViewElement>
ControlNamePrefixAdjuster<T>prefixControlNames(@NonNull String prefix) CreateControlNamePrefixAdjusterpreconfigured 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 voidprefixControlNames(@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) CreateControlNamePrefixAdjusterpreconfigured to update all control names that match the initial prefix, and replace said prefix with the new value.static voidreplaceControlNamesPrefix(@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 firstFormControlElementinstance that is not anInputGroupFormElement. It is possible that the instance itself is returned. This method will recurse throughContainerViewElementtypes until an instance is returned.- Parameters:
viewElement- instance- Returns:
- form control instance, or
nullif 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 firstFormControlElementinstance that matches the expected type. It is possible that the instance itself is returned. This method will recurse throughContainerViewElementtypes until an instance is returned.- Parameters:
viewElement- instanceexpectedType- the control should have- Returns:
- form control instance, or
nullif 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 uniqueFormInputElementcontrols and ensure they are prefixed only once. When it encounters aFormControlElement.Proxyit will also exclude the targetViewElementfrom 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)andControlNamePrefixAdjusterif 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)andControlNamePrefixAdjusterif 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) CreateControlNamePrefixAdjusterpreconfigured 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 aConsumerandViewElementPostProcessor.- 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) CreateControlNamePrefixAdjusterpreconfigured 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 aConsumerandViewElementPostProcessor.- Parameters:
prefixToReplace- prefix that should be replacednewPrefix- prefix that should be used instead- Returns:
- adjuster instance
-