Class HtmlImageInput

All Implemented Interfaces:
Serializable, Cloneable, DisabledElement, FormFieldWithNameHistory, LabelableElement, SubmittableElement, ValidatableElement, Element, Node

public class HtmlImageInput extends HtmlInput implements LabelableElement
Wrapper for the HTML element "input". HtmlUnit does not download the associated image for performance reasons.
See Also:
  • Method Details

    • getSubmitNameValuePairs

      public NameValuePair[] getSubmitNameValuePairs()

      Returns an array of NameValuePairs that are the values that will be sent back to the server whenever this element's containing form is submitted.

      THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK.

      Specified by:
      getSubmitNameValuePairs in interface SubmittableElement
      Overrides:
      getSubmitNameValuePairs in class HtmlInput
      Returns:
      the values that will be sent back to the server whenever this element's containing form is submitted
    • click

      public Page click() throws IOException
      Submit the form that contains this input. Only a couple of the inputs support this method so it is made protected here. Those subclasses that wish to expose it will override and make it public.
      Overrides:
      click in class DomElement
      Returns:
      the Page that is the result of submitting this page to the server
      Throws:
      IOException - If an IO error occurs
    • doClickStateUpdate

      protected boolean doClickStateUpdate(boolean shiftKey, boolean ctrlKey) throws IOException
      This method implements the control state update part of the click action.

      The default implementation only calls doClickStateUpdate on parent's DomElement (if any). Subclasses requiring different behavior (like HtmlSubmitInput) will override this method.

      Overrides:
      doClickStateUpdate in class DomElement
      Parameters:
      shiftKey - true if SHIFT is pressed
      ctrlKey - true if CTRL is pressed
      Returns:
      true if doClickFireEvent method has to be called later on (to signal, that the value was changed)
      Throws:
      IOException - if an IO error occurred
    • click

      public <P extends Page> P click(int x, int y) throws IOException, ElementNotFoundException
      Simulate clicking this input with a pointing device. The x and y coordinates of the pointing device will be sent to the server.
      Type Parameters:
      P - the page type
      Parameters:
      x - the x coordinate of the pointing device at the time of clicking
      y - the y coordinate of the pointing device at the time of clicking
      Returns:
      the page that is loaded after the click has taken place
      Throws:
      IOException - If an IO error occurs
      ElementNotFoundException - If a particular XML element could not be found in the DOM model
    • click

      public <P extends Page> P click(org.htmlunit.javascript.host.event.Event event, boolean shiftKey, boolean ctrlKey, boolean altKey, boolean ignoreVisibility) throws IOException
      INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
      Simulates clicking on this element, returning the page in the window that has the focus after the element has been clicked. Note that the returned page may or may not be the same as the original page, depending on the type of element being clicked, the presence of JavaScript action listeners, etc.
      Overrides:
      click in class DomElement
      Type Parameters:
      P - the page type
      Parameters:
      event - the click event used
      shiftKey - true if SHIFT is pressed during the click
      ctrlKey - true if CTRL is pressed during the click
      altKey - true if ALT is pressed during the click
      ignoreVisibility - whether to ignore visibility or not
      Returns:
      the page contained in the current window as returned by WebClient.getCurrentWindow()
      Throws:
      IOException - if an IO error occurs
    • setValue

      public void setValue(String newValue)
      Sets the value.
      Overrides:
      setValue in class HtmlInput
      Parameters:
      newValue - the new value
    • setDefaultChecked

      public void setDefaultChecked(boolean defaultChecked)
      Sets the default checked state to use when this element gets reset, if applicable. The default implementation is empty; only checkboxes and radio buttons really care what the default checked value is.
      Specified by:
      setDefaultChecked in interface SubmittableElement
      Parameters:
      defaultChecked - the default checked state to use when this element gets reset, if applicable
      See Also:
    • setDefaultValue

      public void setDefaultValue(String defaultValue)
      Sets the default value to use when this element gets reset, if applicable. Also sets the value to the new default value.
      Specified by:
      setDefaultValue in interface SubmittableElement
      Overrides:
      setDefaultValue in class HtmlInput
      Parameters:
      defaultValue - the default value to use when this element gets reset, if applicable
      See Also:
    • isRequiredSupported

      protected boolean isRequiredSupported()
      Returns whether this element supports the required constraint.
      Overrides:
      isRequiredSupported in class HtmlInput
      Returns:
      whether this element supports the required constraint
    • setSrcAttribute

      public void setSrcAttribute(String src)
      Sets the src attribute.
      Overrides:
      setSrcAttribute in class HtmlInput
      Parameters:
      src - the src attribute
    • saveAs

      public void saveAs(File file) throws IOException
      Saves this image as the specified file.
      Parameters:
      file - the file to save to
      Throws:
      IOException - if an IO error occurs