Class AjaxEditableLabel<T>

    • Method Detail

      • updateLabelAjaxAttributes

        protected void updateLabelAjaxAttributes​(AjaxRequestAttributes attributes)
        Gives a chance to the specializations to modify the Ajax attributes for the request when this component switches from an editor to a label.
        Parameters:
        attributes - The Ajax attributes to modify
      • updateEditorAjaxAttributes

        protected void updateEditorAjaxAttributes​(AjaxRequestAttributes attributes)
        Gives a chance to the specializations to modify the Ajax attributes for the request when this component switches from a label to an editor.
        Parameters:
        attributes - The Ajax attributes to modify
      • setLabel

        public final AjaxEditableLabel<TsetLabel​(IModel<String> labelModel)
        The value will be made available to the validator property by means of ${label}. It does not have any specific meaning to FormComponent itself.
        Parameters:
        labelModel -
        Returns:
        this for chaining
      • setRequired

        public final AjaxEditableLabel<TsetRequired​(boolean required)
        Sets the required flag
        Parameters:
        required -
        Returns:
        this for chaining
      • setType

        public final AjaxEditableLabel<TsetType​(Class<?> type)
        Sets the type that will be used when updating the model for this component. If no type is specified String type is assumed.
        Parameters:
        type -
        Returns:
        this for chaining
      • newEditor

        protected FormComponent<TnewEditor​(MarkupContainer parent,
                                             String componentId,
                                             IModel<T> model)
        Create a new form component instance to serve as editor.
        Parameters:
        parent - The parent component
        componentId - Id that should be used by the component
        model - The model
        Returns:
        The editor
      • shouldTrimInput

        protected boolean shouldTrimInput()
        Determines whether or not the textfield should trim its input prior to processing it. The default value is true
        Returns:
        True if the input should be trimmed.
      • newLabel

        protected Component newLabel​(MarkupContainer parent,
                                     String componentId,
                                     IModel<T> model)
        Create a new form component instance to serve as label.
        Parameters:
        parent - The parent component
        componentId - Id that should be used by the component
        model - The model
        Returns:
        The editor
      • getLabelAjaxEvent

        protected String getLabelAjaxEvent()
        By default this returns "click", users can overwrite this on which event the label behavior should be triggered
        Returns:
        The event name
      • getEditor

        protected final FormComponent<TgetEditor()
        Gets the editor component.
        Returns:
        The editor component
      • getLabel

        protected final Component getLabel()
        Gets the label component.
        Returns:
        The label component
      • onBeforeRender

        protected void onBeforeRender()
        Description copied from class: Component
        Called on all visible components before any component is rendered.

        NOTE: If you override this, you *must* call super.onBeforeRender() within your implementation. Because this method is responsible for cascading Component.onBeforeRender() call to its children it is strongly recommended that super call is made at the end of the override.

        Changes to the component tree can be made only before calling super.onBeforeRender().
        Overrides:
        onBeforeRender in class Component
        See Also:
        MarkupContainer.addOrReplace(Component...)
      • onCancel

        protected void onCancel​(AjaxRequestTarget target)
        Invoked when the label is in edit mode, and received a cancel event. Typically, nothing should be done here.
        Parameters:
        target - the ajax request target
      • onEdit

        public void onEdit​(AjaxRequestTarget target)
        Called when the label is clicked and the component is put in edit mode.
        Parameters:
        target - Ajax target
      • onError

        protected void onError​(AjaxRequestTarget target)
        Invoked when the label is in edit mode, received a new input, but that input didn't validate
        Parameters:
        target - the ajax request target
      • onSubmit

        protected void onSubmit​(AjaxRequestTarget target)
        Invoked when the editor was successfully updated. Use this method e.g. to persist the changed value. This implementation displays the label and clears any window status that might have been set in onError.
        Parameters:
        target - The ajax request target
      • defaultNullLabel

        protected String defaultNullLabel()
        Override this to display a different value when the model object is null. Default is ...
        Returns:
        The string which should be displayed when the model object is null.