Class InputElement

  • Direct Known Subclasses:
    FileElement, ImageButtonElement

    public class InputElement
    extends HtmlElement
    Represents an HTML input element within an HTML form. An HTML element is everything from the start tag to the end tag.

    e.g. <input type="text" name="firstname"> would be represented by a single InputElement object.

    An InputElement is submitted as a key/value pair when the containing Form is sent to the web server.

    See Also:
    Form
    • Constructor Detail

      • InputElement

        public InputElement​(long cPtr,
                            boolean cMemoryOwn)
        For internal use only. Of no interest to the user.
        Parameters:
        cPtr - pointer to the CPP wrapped object
        cMemoryOwn - indicates if this object is responsible for memory management of the CPP object
      • InputElement

        public InputElement​(java.lang.String name,
                            java.lang.String value,
                            java.lang.String encoding)
                     throws java.io.UnsupportedEncodingException
        Creates an InputElement object with the specified name and value attributes, and encoded with the specified character encoding.
        Parameters:
        name - the value to assign to the "name" attribute
        value - the value to assign to the "value" attribute
        encoding - the character encoding to use when encoding the name/value
        Throws:
        java.io.UnsupportedEncodingException - The encoding is not supported
      • InputElement

        public InputElement​(java.lang.String name,
                            java.lang.String value)
                     throws java.io.UnsupportedEncodingException
        Creates an InputElement object with the specified name and value attributes.
        Parameters:
        name - the value to assign to the "name" attribute
        value - the value to assign to the "value" attribute
        Throws:
        java.io.UnsupportedEncodingException - The encoding is not supported
    • Method Detail

      • getCPtr

        public static long getCPtr​(InputElement obj)
        For internal use only. Of no interest to the user.
        Parameters:
        obj - a reference to an object of this class
        Returns:
        a long containing the address of the CPP wrapped object
      • makeFrom

        public static InputElement makeFrom​(HtmlElement htmlElement)
        For internal use only. Of no interest to the user.
        Parameters:
        htmlElement - Internal use only.
        Returns:
        a new InputElement
      • getType

        public InputElement.InputElementType getType()
        Gets the type of this InputElement. This method is similar to getAttribute("type"), but returns the type as an enum value.
        Returns:
        the type of this InputElement
      • isChecked

        public boolean isChecked()
        Returns true if the "checked" attribute has been set for this InputElement. This method is equivalent to hasAttribute("checked").
        Returns:
        true if the "checked" attribute exists in this InputElement
        See Also:
        setChecked(boolean)
      • setChecked

        public void setChecked​(boolean checked)
        Sets or removes the "checked" attribute for this InputElement.

        setChecked(true) is equivalent to setAttribute("checked").

        setChecked(false) is equivalent to removeAttribute("checked").

        Parameters:
        checked - true to check the input element, false to uncheck it
        See Also:
        isChecked()
      • setSubmitted

        public void setSubmitted​(boolean value)
        Sets a value indicating whether this InputElement has been submitted. For example, a button is submitted when it is pressed.
        Parameters:
        value - whether this InputElement should be submitted or not
      • isSubmitted

        public boolean isSubmitted()
        Returns true if this InputElement has been submitted. For example, a button is submitted when it is pressed.
        Returns:
        true if this InputElement was submitted
      • isSuccessfulControl

        public boolean isSuccessfulControl()
        Returns true if this InputElement represents a successful control. A successful control is valid for submission. Every successful control has its control name and current value submitted when the form is sent to the web server.
        Overrides:
        isSuccessfulControl in class HtmlElement
        Returns:
        true if this InputElement represents a successful control
      • clone

        public HtmlElement clone()
        Description copied from class: HtmlElement
        Creates a copy of this HTML element.
        Overrides:
        clone in class HtmlElement
        Returns:
        a new HtmlElement object which is an exact copy of this HTML element