Interface Input

    • Method Detail

      • addValidator

        void addValidator​(FieldValidator validator)
        Adds a validator to the input field. Validators are not automatically called on form submission. Using a ValidatingAction or an explicit call to WComponent.validate(List) will trigger validation on a WComponent tree.
        Parameters:
        validator - the validator to add.
      • getValidators

        Iterator<FieldValidator> getValidators()
        Returns:
        the list of validators for this input field.
      • setActionOnChange

        void setActionOnChange​(Action actionOnChange)
        Sets the action that you want run if the input is changed by the user. The action command will be set to the new value of the input.
        Parameters:
        actionOnChange - the action to execute when the input is changed by the user.
      • getActionOnChange

        Action getActionOnChange()
        Returns:
        the action to execute when the input is changed by the user.
      • getActionObject

        Object getActionObject()
        Returns the data object that has been associated with this input component, else null. For convenience, this data object is passed to the execute() method of the button's associated Action, in the ActionEvent parameter.
        Returns:
        the data object that has been associated with this input component.
      • setActionObject

        void setActionObject​(Object data)
        Associates this input with a data object that can be easily accessed in the execute() method of the associated Action.
        Parameters:
        data - the data object.
      • getActionCommand

        String getActionCommand()
        Same as {#getValueAsString()}. This method exists simply to clarify the relationship between the input component, its Action, and the ActionEvent sent to the execute() method of the Action.
        Returns:
        the current selection, as a string.
      • setDefaultSubmitButton

        void setDefaultSubmitButton​(WButton defaultSubmitButton)
        Sets the button that should be submitted when the user hits enter key and cursor is inside this input field.
        Parameters:
        defaultSubmitButton - the default submit button for this field.
      • getDefaultSubmitButton

        WButton getDefaultSubmitButton()
        Returns:
        the button that will be submitted if the user hits the enter key when the cursor is in this field.
      • setMandatory

        void setMandatory​(boolean mandatory,
                          String message)
        Set whether or not this input is mandatory, and customise the error message that will be displayed.
        Parameters:
        mandatory - true for mandatory, false for optional.
        message - the message to display to the user on mandatory validation failure.
      • isReadOnly

        boolean isReadOnly()
        Indicates whether the input is read only in the given context.
        Returns:
        true if the input is read only, otherwise false.
      • setReadOnly

        void setReadOnly​(boolean readOnly)
        Sets whether the input is read only.
        Parameters:
        readOnly - if true, the input is read only. If false, it is editable.
      • getRequestValue

        Object getRequestValue​(Request request)
        Provide the value of the component on the Request.

        If the component is not on the request, the components current value will be provided.

        Parameters:
        request - the request being responded to.
        Returns:
        the value of this component on the Request, or its current state if it is not on the request.
      • getValue

        Object getValue()
        Provide the value of the component returned by DataBound.getData() in the correct format.

        If required, this method can convert the data into the correct type and also do any validation before the value is used.

        Returns:
        the value of the component returned by DataBound.getData() in the correct format.
      • getValueAsString

        String getValueAsString()
        Retrieves a String representation of the input field's value.
        Returns:
        the String representation of the input field's value
      • isEmpty

        boolean isEmpty()
        Indicates whether this input field is empty. An input is considered empty if the value is null or an empty String.
        Returns:
        true if this input field is empty, false otherwise.
      • isChangedInLastRequest

        boolean isChangedInLastRequest()
        Indicates if the input component was changed in the last request.
        Returns:
        true if the input was changed in the last request.