Class Button

    • Constructor Detail

      • Button

        public Button​(String id)
        Constructor without a model. Buttons without models leave the markup attribute "value". Provide a model if you want to set the button's label dynamically.
        See Also:
        Component(String)
      • Button

        public Button​(String id,
                      IModel<String> model)
        Constructor taking an model for rendering the 'label' of the button (the value attribute of the input/button tag). Use a StringResourceModel for a localized value.
        Parameters:
        id - Component id
        model - The model property is used to set the "value" attribute. It will thus be the label of the button that shows up for end users. If you want the attribute to keep it's markup attribute value, don't provide a model, or let it return an empty string.
    • Method Detail

      • getDefaultFormProcessing

        public final boolean getDefaultFormProcessing()
        Gets the defaultFormProcessing property. When false (default is true), all validation and formupdating is bypassed and the onSubmit method of that button is called directly, and the onSubmit method of the parent form is not called. A common use for this is to create a cancel button.
        Specified by:
        getDefaultFormProcessing in interface IFormSubmitter
        Returns:
        defaultFormProcessing
      • setDefaultFormProcessing

        public final Button setDefaultFormProcessing​(boolean defaultFormProcessing)
        Sets the defaultFormProcessing property. When false (default is true), all validation and form updating is bypassed and the onSubmit method of that button is called directly, and the onSubmit method of the parent form is not called. A common use for this is to create a cancel button.
        Specified by:
        setDefaultFormProcessing in interface IFormSubmittingComponent
        Parameters:
        defaultFormProcessing - defaultFormProcessing
        Returns:
        This
      • getOnClickScript

        protected String getOnClickScript()
        Gets any script that should rendered as a "click" event handler for the button. Returns null by default, override this method to provide any script.
        Returns:
        Any onClick JavaScript that should be used, returns null by default
      • onComponentTagBody

        public void onComponentTagBody​(MarkupStream markupStream,
                                       ComponentTag openTag)
        Description copied from class: MarkupContainer
        Handle the container's body. If your override of this method does not advance the markup stream to the close tag for the openTag, a runtime exception will be thrown by the framework.
        Overrides:
        onComponentTagBody in class MarkupContainer
        Parameters:
        markupStream - The markup stream
        openTag - The open tag for the body
      • onError

        public void onError()
        Description copied from interface: IFormSubmitter
        Method that is invoked when form processing fails; for example, when there are validation errors.
        Specified by:
        onError in interface IFormSubmitter
      • onSubmit

        public void onSubmit()
        Override this method to provide special submit handling in a multi-button form. It is called whenever the user clicks this particular button, except if validation fails. This method will be called before Form.onSubmit().
        Specified by:
        onSubmit in interface IFormSubmitter
      • onAfterSubmit

        public void onAfterSubmit()
        Override this method to provide special submit handling in a multi-button form. It is called whenever the user clicks this particular button, except if validation fails. This method will be called after Form.onSubmit().
        Specified by:
        onAfterSubmit in interface IFormSubmitter