Class BootstrapElementUtils

java.lang.Object
com.foreach.across.modules.bootstrapui.utils.BootstrapElementUtils

public abstract class BootstrapElementUtils extends Object
Contains several static utility methods for working with elements.
Author:
Arne Vandamme
  • Constructor Details

    • BootstrapElementUtils

      protected BootstrapElementUtils()
  • Method Details

    • getFormControl

      public static FormControlElement getFormControl(com.foreach.across.modules.web.ui.ViewElement viewElement)
      Will search for the first FormControlElement instance that is not an InputGroupFormElement. It is possible that the instance itself is returned. This method will recurse through ContainerViewElement 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 first FormControlElement instance that matches the expected type. It is possible that the instance itself is returned. This method will recurse through ContainerViewElement types until an instance is returned.
      Parameters:
      viewElement - instance
      expectedType - 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 unique FormInputElement controls and ensure they are prefixed only once. When it encounters a FormControlElement.Proxy it will also exclude the target ViewElement 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.

      See prefixControlNames(String) and ControlNamePrefixAdjuster if you want to customize.

      Parameters:
      prefix - to apply to any input element
      container - 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. Like prefixControlNames(String, ContainerViewElement) this method should handle different form control elements correctly.

      See replaceControlNamesPrefix(String, String) and ControlNamePrefixAdjuster if you want to customize.

      Parameters:
      prefixToReplace - prefix that should be replaced
      newPrefix - prefix that should be used instead
      container - 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)
      Create ControlNamePrefixAdjuster 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 a Consumer and ViewElementPostProcessor.

      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)
      Create ControlNamePrefixAdjuster preconfigured to update all control names that match the initial prefix, and replace said prefix with the new value. Like prefixControlNames(String) the return value is preconfigured to recurse through container members, ignore underscores and add dot separators where necessary.

      The return value is both a Consumer and ViewElementPostProcessor.

      Parameters:
      prefixToReplace - prefix that should be replaced
      newPrefix - prefix that should be used instead
      Returns:
      adjuster instance