Class Input<T extends Input<T>>

Direct Known Subclasses:
ButtonInput, Checkbox, ColorInput, DateInput, DateTimeInput, DateTimeLocalInput, EmailInput, FileInput, HiddenInput, ImageInput, MonthInput, NumberInput, PasswordInput, RadioButton, RangeInput, ResetInput, SearchInput, SubmitButton, TelephoneInput, TextInput, TimeInput, UrlInput, WeekInput

public class Input<T extends Input<T>> extends InputElement<T>
Represents the HTML <input> element, the foundation for various form input types.

The Input class provides a Java representation of the HTML input element, which is one of the most versatile form elements in HTML. It supports numerous input types including text, password, email, number, date, checkbox, radio, file, and many more. This class serves as the base implementation with type constants and can be extended for specialized input types.

Features:

  • Support for all HTML5 input types via constants
  • Auto-focus capability for keyboard navigation
  • Event registration for input changes and completion
  • Type-safe input type configuration
  • Extensible design for specialized input implementations
  • Automatic event attribute generation for listeners
  • Support for both client-side and server-side event handling

Input Type Constants:

  • TEXT - Single-line text input
  • PASSWORD - Masked password input
  • EMAIL - Email address input with validation
  • NUMBER - Numeric input with spinner controls
  • DATE, TIME, DATETIME, DATETIME_LOCAL - Date/time pickers
  • CHECKBOX, RADIO - Selection controls
  • FILE - File upload control
  • COLOR - Color picker
  • RANGE - Slider control
  • And many more...

Usage Example:


 // Create a text input
 Input textInput = new Input();
 textInput.setType(Input.TEXT);
 textInput.setName("username");
 textInput.setAutoFocus();

 // Create a number input
 Input numberInput = new Input(Input.NUMBER, false);
 numberInput.setName("quantity");

 // Create an email input with change listener
 Input emailInput = new Input();
 emailInput.setType(Input.EMAIL);
 emailInput.registerListener(new InputChangeListener() {
     public void onEvent(InputChangeEvent event) {
         // Handle input change
     }
 }, InputChangeEvent.class);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Field Details

  • Constructor Details

    • Input

      public Input()
      Creates a new Input element with the default text type.
    • Input

      public Input(String type, boolean closed)
      Creates a new Input element with the specified type and tag closure mode.
      Parameters:
      type - The input type (e.g., TEXT, PASSWORD, EMAIL).
      closed - true for a closed tag, false for a self-closing tag.
  • Method Details

    • setAutoFocus

      public final void setAutoFocus()
      Enables auto-focus on this input element so it receives keyboard focus when the page loads.
    • setType

      protected final T setType(String type)
      Sets the input type attribute.
      Parameters:
      type - The input type (e.g., TEXT, PASSWORD, EMAIL).
    • getType

      public final String getType()
      Returns the input type attribute.
      Returns:
      The input type (e.g., "text", "password", "email").
    • registerListener

      public void registerListener(ClientEventListener listener, Class<? extends ClientEvent> eventType)
      Registers a client event listener for this input element.

      In addition to standard event registration, this method automatically adds the appropriate data attributes to enable InputChangeEvent and InputCompleteEvent generation on the client side.

      Overrides:
      registerListener in class Element<T extends Input<T>>
      Parameters:
      listener - The event listener to register.
      eventType - The class of the client event to listen for.