java.lang.Object
org.apache.wicket.behavior.Behavior
de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapBaseBehavior
de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapJavascriptBehavior
de.agilecoders.wicket.extensions.markup.html.bootstrap.inputmask.InputMaskBehavior
All Implemented Interfaces:
Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, IClusterable

public class InputMaskBehavior extends de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapJavascriptBehavior
Behavior that adds mask to input components.
Author:
Jan Ferko
See Also:
  • Constructor Details

    • InputMaskBehavior

      public InputMaskBehavior(String mask)
      Constructs new behavior for given mask.
      Parameters:
      mask - the mask used in component
    • InputMaskBehavior

      public InputMaskBehavior(InputMaskConfig config)
      Constructs new behavior for given configuration.
      Parameters:
      config - the input mask configuration
  • Method Details

    • renderHead

      public void renderHead(Component component, IHeaderResponse headerResponse)
      Specified by:
      renderHead in interface IComponentAwareHeaderContributor
      Overrides:
      renderHead in class de.agilecoders.wicket.core.markup.html.bootstrap.behavior.BootstrapBaseBehavior
    • mask

      public InputMaskBehavior mask(String mask)
      Set mask for the input.
      Parameters:
      mask - the mask for the input.
      Returns:
      this instance
    • placeholder

      public InputMaskBehavior placeholder(String placeholder)
      Sets mask placeholder.
      Parameters:
      placeholder - The mask placeholder.
      Returns:
      this instance
    • regex

      public InputMaskBehavior regex(String regex)
      Sets regular expression to use as a mask. When using shorthands be aware that you need to double escape them.
      Parameters:
      regex - The regular expression to use as a mask.
      Returns:
      this config instance
    • repeat

      public InputMaskBehavior repeat(int repeat)
      Repeat the mask definition x-times.
      Parameters:
      repeat - the number of times mask is repeated.
      Returns:
      this config instance
    • greedy

      public InputMaskBehavior greedy(boolean greedy)
      Toggle to allocate as much possible or the opposite.
      Parameters:
      greedy - Toggle to allocate as much possible or the opposite.
      Returns:
      this instance
    • autoUnmask

      public InputMaskBehavior autoUnmask(boolean autoUnmask)
      Automatically unmask the value when retrieved.
      Parameters:
      autoUnmask - Toggle automatic unmasking when value is retrieved.
      Returns:
      this instance
    • removeMaskOnSubmit

      public InputMaskBehavior removeMaskOnSubmit(boolean removeMaskOnSubmit)
      Remove the mask before submitting the form.
      Parameters:
      removeMaskOnSubmit - Toggle mask removing before form submitting
      Returns:
      this instace
    • clearMarkOnLostFocus

      public InputMaskBehavior clearMarkOnLostFocus(boolean clearMaskOnFocus)
      Remove the empty mask on blur or when not empty removes the optional trailing part.
      Parameters:
      clearMaskOnFocus - Toggle to empty mask on blur or optional trailing part if mask is empty
      Returns:
      this instance
    • insertMode

      public InputMaskBehavior insertMode(boolean insertMode)
      Toggle to insert or overwrite input. This option can be altered by pressing the Insert key.
      Parameters:
      insertMode - Toggle to insert or overwrite input
      Returns:
      this instance
    • clearIncomplete

      public InputMaskConfig clearIncomplete(boolean clearIncomplete)
      Clear the incomplete input on blur.
      Parameters:
      clearIncomplete - Toggle to clear the incomplete input on blur.
      Returns:
      this instance
    • showMaskOnFocus

      public InputMaskConfig showMaskOnFocus(boolean showMaskOnFocus)
      Shows the mask when the input gets focus.
      Parameters:
      showMaskOnFocus - Toggle to show the mask when inpus gets focus.
      Returns:
      this instance
    • showMaskOnHover

      public InputMaskConfig showMaskOnHover(boolean showMaskOnHover)
      Shows the mask when hovering the mouse.
      Parameters:
      showMaskOnHover - Toggle to show the mask when hovering the mouse.
      Returns:
      this instance
    • numericInput

      public InputMaskConfig numericInput(boolean numericInput)
      Numeric input direction. Keeps the caret at the end.
      Parameters:
      numericInput - Toggle to keep the caret at the end
      Returns:
      this instance
    • rightAlign

      public InputMaskConfig rightAlign(boolean rightAlign)
      Align the input to the right. This is only applied in combination op the numericInput option or the dir-attribute.
      Parameters:
      rightAlign - Toggle right input alignment
      Returns:
      this instance
    • undoOnEscape

      public InputMaskConfig undoOnEscape(boolean undoOnEscape)
      Make escape behave like undo. (ctrl-Z) Pressing escape reverts the value to the value before focus.
      Parameters:
      undoOnEscape - Toggle to make escape behave like undo
      Returns:
      this instance
    • positionCaretOnTab

      public InputMaskConfig positionCaretOnTab(boolean positionCaretOnTab)
      When enabled the caret position is set after the latest valid position on TAB.
      Parameters:
      positionCaretOnTab - Enable to set caret position after the latest valid position on TAB
      Returns:
      this instance
    • tabThrough

      public InputMaskConfig tabThrough(boolean tabThrough)
      Allows for tabbing through the different parts of the masked field.
      Parameters:
      tabThrough - Toggle to allow for tabbing through the different parts of the masked field.
      Returns:
      this instance
    • nullable

      public InputMaskConfig nullable(boolean nullable)
      Return nothing when the user hasn't entered anything.
      Parameters:
      nullable - Toggle to return nothing if user hasn't entered anything
      Returns:
      this instance
    • positionCaretOnClick

      public InputMaskConfig positionCaretOnClick(InputMaskConfig.CaretPosition position)
      Positioning of the caret on click.
      Parameters:
      position - position of caret on click
      Returns:
      this instance