Class FormViewElement

java.lang.Object
com.foreach.across.modules.web.ui.elements.ContainerViewElement
com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
com.foreach.across.modules.bootstrapui.elements.FormViewElement
All Implemented Interfaces:
com.foreach.across.modules.web.ui.elements.HtmlViewElement, com.foreach.across.modules.web.ui.MutableViewElement, com.foreach.across.modules.web.ui.ViewElement

public class FormViewElement extends com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
Represents a HTML form element, supporting a Bootstrap FormLayout that will automatically be applied to all controls of the form that do not have a separate layout specified.
Author:
Arne Vandamme
  • Field Details

  • Constructor Details

    • FormViewElement

      public FormViewElement()
  • Method Details

    • getFormLayout

      public FormLayout getFormLayout()
    • setFormLayout

      public FormViewElement setFormLayout(FormLayout formLayout)
      Set the FormLayout that should be applied to all FormGroupElement members of this form. Also set the corresponding class.
      Parameters:
      formLayout - instance
    • getCommandAttribute

      public String getCommandAttribute()
    • setCommandAttribute

      public FormViewElement setCommandAttribute(String commandAttribute)
      Set the attribute name of the command object that this form is for. All form groups within this form will have the control names prefixed and field errors bound. This is basically the equivalent of putting a th:object attribute on an element in Thymeleaf.
      Parameters:
      commandAttribute - instance
    • getMethod

      public org.springframework.http.HttpMethod getMethod()
    • setMethod

      public FormViewElement setMethod(org.springframework.http.HttpMethod httpMethod)
    • getAction

      public String getAction()
    • setAction

      public FormViewElement setAction(String url)
    • setName

      public FormViewElement setName(String name)
      Specified by:
      setName in interface com.foreach.across.modules.web.ui.MutableViewElement
      Overrides:
      setName in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • getFormName

      public String getFormName()
      Returns:
      name attribute of the form
    • setFormName

      public FormViewElement setFormName(String name)
      Set the HTML name attribute of this form. Defaults to ContainerViewElement.getName().
      Parameters:
      name - attribute to use
    • getEncType

      public String getEncType()
    • setEncType

      public FormViewElement setEncType(String encType)
      Set encoding type (enctype attribute) to use for this form.
      Parameters:
      encType - value
    • getAcceptCharSet

      public String getAcceptCharSet()
    • setAcceptCharSet

      public FormViewElement setAcceptCharSet(String charSet)
    • isAutoComplete

      public boolean isAutoComplete()
    • setAutoComplete

      public FormViewElement setAutoComplete(boolean autoComplete)
    • isNoValidate

      public boolean isNoValidate()
    • setNoValidate

      public FormViewElement setNoValidate(boolean noValidate)
    • addCssClass

      public FormViewElement addCssClass(String... cssClass)
      Specified by:
      addCssClass in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      addCssClass in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • removeCssClass

      public FormViewElement removeCssClass(String... cssClass)
      Specified by:
      removeCssClass in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      removeCssClass in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setAttributes

      public FormViewElement setAttributes(Map<String,Object> attributes)
      Specified by:
      setAttributes in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      setAttributes in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setAttribute

      public FormViewElement setAttribute(String attributeName, Object attributeValue)
      Specified by:
      setAttribute in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      setAttribute in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • addAttributes

      public FormViewElement addAttributes(Map<String,Object> attributes)
      Specified by:
      addAttributes in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      addAttributes in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • removeAttribute

      public FormViewElement removeAttribute(String attributeName)
      Specified by:
      removeAttribute in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      removeAttribute in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setCustomTemplate

      public FormViewElement setCustomTemplate(String customTemplate)
      Specified by:
      setCustomTemplate in interface com.foreach.across.modules.web.ui.MutableViewElement
      Overrides:
      setCustomTemplate in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setElementType

      protected FormViewElement setElementType(String elementType)
      Overrides:
      setElementType in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • addChild

      public FormViewElement addChild(com.foreach.across.modules.web.ui.ViewElement element)
      Overrides:
      addChild in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • addChildren

      public FormViewElement addChildren(Collection<? extends com.foreach.across.modules.web.ui.ViewElement> elements)
      Overrides:
      addChildren in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • addFirstChild

      public FormViewElement addFirstChild(com.foreach.across.modules.web.ui.ViewElement element)
      Overrides:
      addFirstChild in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • clearChildren

      public FormViewElement clearChildren()
      Overrides:
      clearChildren in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • apply

      public FormViewElement apply(Consumer<com.foreach.across.modules.web.ui.elements.ContainerViewElement> consumer)
      Overrides:
      apply in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • applyUnsafe

      public <U extends com.foreach.across.modules.web.ui.ViewElement> FormViewElement applyUnsafe(Consumer<U> consumer)
      Overrides:
      applyUnsafe in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setTagName

      protected FormViewElement setTagName(String tagName)
      Overrides:
      setTagName in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • setHtmlId

      public FormViewElement setHtmlId(String htmlId)
      Specified by:
      setHtmlId in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Overrides:
      setHtmlId in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • set

      public FormViewElement set(com.foreach.across.modules.web.ui.ViewElement.WitherSetter... setters)
      Specified by:
      set in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Specified by:
      set in interface com.foreach.across.modules.web.ui.MutableViewElement
      Specified by:
      set in interface com.foreach.across.modules.web.ui.ViewElement
      Overrides:
      set in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • remove

      public FormViewElement remove(com.foreach.across.modules.web.ui.ViewElement.WitherRemover... functions)
      Specified by:
      remove in interface com.foreach.across.modules.web.ui.elements.HtmlViewElement
      Specified by:
      remove in interface com.foreach.across.modules.web.ui.MutableViewElement
      Specified by:
      remove in interface com.foreach.across.modules.web.ui.ViewElement
      Overrides:
      remove in class com.foreach.across.modules.web.ui.elements.AbstractNodeViewElement
    • getCommandObject

      public Object getCommandObject()
      Set the command object that this form is bound to. Can be used as an alternative to setCommandAttribute(String) if you do not know the model attribute name. In this case the same instance of the object is expected to be present as a request attribute, where its attribute name will be looked for.

      Note that a value for commandAttribute will always take precedence over the actual object.

    • setCommandObject

      public FormViewElement setCommandObject(Object commandObject)
      Set the command object that this form is bound to. Can be used as an alternative to setCommandAttribute(String) if you do not know the model attribute name. In this case the same instance of the object is expected to be present as a request attribute, where its attribute name will be looked for.

      Note that a value for commandAttribute will always take precedence over the actual object.

      Returns:
      this.
    • getErrors

      public org.springframework.validation.Errors getErrors()
      Set the collection of Errors for this form. Usually contains the BindingResult for the object bound to this form. Though setting the object is not strictly required.

      When set, any commandAttribute or commandObject will be ignored.

    • setErrors

      public FormViewElement setErrors(org.springframework.validation.Errors errors)
      Set the collection of Errors for this form. Usually contains the BindingResult for the object bound to this form. Though setting the object is not strictly required.

      When set, any commandAttribute or commandObject will be ignored.

      Returns:
      this.