Class ImageInput<T extends ImageInput<T>>


public class ImageInput<T extends ImageInput<T>> extends Input<T>
HTML image input element for graphical submit buttons.

This class extends Input to provide an image-based submit button where clicking the image submits the form and sends the click coordinates. Supports HTML5 form attributes to override form submission behavior.

Features:

  • Image-based form submission
  • Click coordinate submission (x, y)
  • Override form action, method, encoding, and target
  • Custom image source

Usage:

 ImageInput imageBtn = new ImageInput("submitBtn");
 imageBtn.setSrc("/images/submit-button.png");
 imageBtn.setFormAction("/submit");
 
Since:
2015
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • ImageInput

      public ImageInput()
      Constructs a new image input element.
    • ImageInput

      public ImageInput(String name)
      Constructs a new image input with the specified name.
      Parameters:
      name - The name attribute for form submission.
    • ImageInput

      public ImageInput(String name, String value)
      Constructs a new image input with the specified name and value.
      Parameters:
      name - The name attribute for form submission.
      value - The value attribute.
  • Method Details

    • setAlt

      public final T setAlt(String alt)
      Sets the alt attribute providing alternative text for the image input.

      Describes the image button for accessibility when the image cannot be displayed.

      Parameters:
      alt - The alternative text.
      Returns:
      This element for method chaining.
    • setFormAction

      public final T setFormAction(String url)
      Sets the formaction attribute.

      Overrides the form's action attribute for this specific submit button. Used on <input> elements with type="submit" or type="image". The value specifies the URL to submit the form data to.

      If the URL starts with "/" (absolute path within the application), the servlet context path will be automatically prepended.

      Overrides:
      setFormAction in class InputElement<T extends ImageInput<T>>
      Parameters:
      url - The URL for form submission.
      Returns:
      This element for method chaining.
    • setFormEncType

      public final T setFormEncType(FormEncoding encoding)
      Sets the form encoding type override using the FormEncoding enum.
      Overrides:
      setFormEncType in class InputElement<T extends ImageInput<T>>
      Parameters:
      encoding - The encoding type.
      Returns:
      This element for method chaining.
    • setFormEncType

      public final T setFormEncType(String encoding)
      Sets the formenctype attribute.

      Overrides the form's enctype attribute for this specific submit button. Used on <input> elements with type="submit" or type="image".

      Overrides:
      setFormEncType in class InputElement<T extends ImageInput<T>>
      Parameters:
      encoding - The encoding type for form submission.
      Returns:
      This element for method chaining.
    • setFormMethod

      public final T setFormMethod(FormMethod method)
      Sets the form method override using the FormMethod enum.
      Overrides:
      setFormMethod in class InputElement<T extends ImageInput<T>>
      Parameters:
      method - The HTTP method (GET or POST).
      Returns:
      This element for method chaining.
    • setFormMethod

      public final T setFormMethod(String method)
      Sets the formmethod attribute.

      Overrides the form's method attribute for this specific submit button. Used on <input> elements with type="submit" or type="image".

      Overrides:
      setFormMethod in class InputElement<T extends ImageInput<T>>
      Parameters:
      method - The HTTP method for form submission (get, post).
      Returns:
      This element for method chaining.
    • setFormTarget

      public final T setFormTarget(Target target)
      Sets the form target override using the Target enum.
      Overrides:
      setFormTarget in class InputElement<T extends ImageInput<T>>
      Parameters:
      target - The browsing context for form submission.
      Returns:
      This element for method chaining.
    • setFormTarget

      public final T setFormTarget(String target)
      Sets the formtarget attribute.

      Overrides the form's target attribute for this specific submit button, specifying where to display the response. Used on <input> elements with type="submit" or type="image". Values include "_self", "_blank", "_parent", and "_top".

      Overrides:
      setFormTarget in class InputElement<T extends ImageInput<T>>
      Parameters:
      target - The browsing context for form submission.
      Returns:
      This element for method chaining.
    • setSrc

      public final T setSrc(String src)
      Sets the image source URL for the submit button.

      If the URL starts with "/" (absolute path within the application), the servlet context path will be automatically prepended.

      Parameters:
      src - The image source URL.
      Returns:
      This element for method chaining.