org.appng.taglib.form

## Class FormElement

- java.lang.Object
- - javax.servlet.jsp.tagext.TagSupport
  - - javax.servlet.jsp.tagext.BodyTagSupport
    - - org.appng.taglib.form.FormElement

- All Implemented Interfaces:
    Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

      public class FormElement
      extends javax.servlet.jsp.tagext.BodyTagSupport

  This class defines a Form element.

  The `<appNG:formElement>` is used as a wrapper for standard HTML form input fields, which are
  - `<input>`
  - `<textarea>`
  - `<select>`
  - `<option>`

  Attributes:
  All of the following attributes are optional.
  - mandatory - set to `true` if the field is mandatory
  - mandatoryMessage - the message to be displayed when no value has been entered for a mandatory field
  - errorMessage - the error message to be displayed when validation fails
  - errorClass - the CSS class to add to the input field when validation fails
  - errorElementId - the id of an element to append a `<span>` with the error message
  - rule - a validation rule for the input field
  - desc - a description for the input field

  Usage:

       <appNG:formElement errorClass="error" rule="email" mandatory="true" errorElementId="emailError"
              mandatoryMessage="E-mail is mandatory!" errorMessage="Not a valid e-mail!">
         <input type="text" name="email" value=""/>
         <div id="emailError"></div>
       </appNG:formElement>

  Output (no value given):

       <input class="error" type="text" name="email" value=""/>
       <div id="emailError"><span>E-mail is mandatory!</span></div>

  Output (invalid value given):

       <input class="error" type="text" name="email" value=""/>
       <div id="emailError"><span>Not a valid e-mail!</span></div>

  Rules:
  Here's a list of the possible values for the `rule` attribute

  name | description | example
  --- | --- | ---
  string | only word characters ([a-zA-Z_0-9] allowed) | `rule="string"`
  email | must be a valid email address | `rule="email"`
  equals | must be equal to another field or value | `rule="equals('foo')` `rule="equals(anotherfield)`"
  regExp | must match the given regular expression | `rule="regExp('[A-F0-9]+')"`
  number | must be a number | `rule="number"`
  numberFractionDigits | must be a number with up to x digits, and y fractional digits | `rule="number(2,4)"`
  size | must have an exact length of x | `rule="size(3)"`
  sizeMin | must have a minimum length of x | `rule="sizeMin(3)"`
  sizeMax | must have a maximum length of x | `rule="sizeMax(3)"`
  sizeMinMax | must have a minimum length of x and a maximum length of y | `rule="sizeMinMax(3,5)"`
  fileType | must have one of the comma-separated types (`<input type="file">` only) | `rule="fileType('tif,pdf')"`
  fileSizeMin | must have a minimum size of x MB/KB (`<input type="file">` only) | `rule="fileSizeMin('0.5MB')"`
  fileSizeMax | must have a maximum size of x MB/KB (`<input type="file">` only) | `rule="fileSizeMax('5.0MB')"`
  fileSize | must have a size between x and y MB/KB (`<input type="file">` only) | `rule="fileSize('500KB','5.0MB')"`
  fileCount | between x and y files must have been selected (`<input type="file" multiple="true">` only) | `rule="fileCount(1,10)"`
  fileCountMin | at least x files must have been selected (`<input type="file" multiple="true">` only) | `rule="fileCountMin(5)"`
  fileCountMax | at most x files must have been selected (`<input type="file" multiple="true">` only) | `rule="fileCountMax(5)"`
  captcha | Must match a captcha value. The result of the captcha is stored in the variable SESSION['SESSION']['captcha'], where the first SESSION means the HTTP Session, ['SESSION'] the name of an attribute within the HTTP session. Since this attribute is also a map, you can use ['captcha'] to retrieve the result. | `rule="captcha(SESSION['SESSION']['captcha'])`

  Author:
    Matthias Herlitzius, Matthias Müller
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected FormElement` | `wrappedFormElement`

    - ### Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport

      `bodyContent`

    - ### Fields inherited from class javax.servlet.jsp.tagext.TagSupport

      `id, pageContext`

    - ### Fields inherited from interface javax.servlet.jsp.tagext.BodyTag

      `EVAL_BODY_BUFFERED, EVAL_BODY_TAG`

    - ### Fields inherited from interface javax.servlet.jsp.tagext.IterationTag

      `EVAL_BODY_AGAIN`

    - ### Fields inherited from interface javax.servlet.jsp.tagext.Tag

      `EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FormElement()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `doAfterBody()`
    `int` | `doEndTag()`
    `int` | `doStartTag()`
    `String` | `getContent()`
    `String` | `getDesc()`
    `String` | `getErrorClass()`
    `String` | `getErrorElementId()`
    `String` | `getErrorMessage()`
    `FormData` | `getFormData()`
    `FormGroup` | `getFormGroup()`
    `String` | `getMandatoryMessage()`
    `String` | `getName()`
    `String` | `getRule()`
    `protected FormElement` | `getWrappedFormElement()`
    `boolean` | `isForwardValidation()`
    `boolean` | `isMandatory()`
    `String` | `processContent()`
    `void` | `release()`
    `void` | `setContent(String content)`
    `void` | `setDesc(String desc)`
    `void` | `setErrorClass(String errorClass)`
    `void` | `setErrorElementId(String errorElementId)`
    `void` | `setErrorMessage(String errorMessage)`
    `void` | `setForwardValidation(boolean forwardValidation)`
    `void` | `setMandatory(boolean mandatory)`
    `void` | `setMandatoryMessage(String mandatoryMessage)`
    `void` | `setName(String name)`
    `void` | `setRule(String rule)`

    - ### Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport

      `doInitBody, getBodyContent, getPreviousOut, setBodyContent`

    - ### Methods inherited from class javax.servlet.jsp.tagext.TagSupport

      `findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface javax.servlet.jsp.tagext.Tag

      `getParent, setPageContext, setParent`

- - ### Field Detail

    - #### wrappedFormElement

          protected FormElement wrappedFormElement

  - ### Constructor Detail

    - #### FormElement

          public FormElement()

  - ### Method Detail

    - #### doStartTag

          public int doStartTag()
                         throws javax.servlet.jsp.JspException

      Specified by:
        `doStartTag` in interface `javax.servlet.jsp.tagext.Tag`
      Overrides:
        `doStartTag` in class `javax.servlet.jsp.tagext.BodyTagSupport`
      Throws:
        `javax.servlet.jsp.JspException`

    - #### doEndTag

          public int doEndTag()
                       throws javax.servlet.jsp.JspException

      Specified by:
        `doEndTag` in interface `javax.servlet.jsp.tagext.Tag`
      Overrides:
        `doEndTag` in class `javax.servlet.jsp.tagext.BodyTagSupport`
      Throws:
        `javax.servlet.jsp.JspException`

    - #### doAfterBody

          public int doAfterBody()

      Specified by:
        `doAfterBody` in interface `javax.servlet.jsp.tagext.IterationTag`
      Overrides:
        `doAfterBody` in class `javax.servlet.jsp.tagext.BodyTagSupport`

    - #### processContent

          public String processContent()

    - #### isMandatory

          public boolean isMandatory()

    - #### setMandatory

          public void setMandatory(boolean mandatory)

    - #### getRule

          public String getRule()

    - #### setRule

          public void setRule(String rule)

    - #### getErrorClass

          public String getErrorClass()

    - #### setErrorClass

          public void setErrorClass(String errorClass)

    - #### isForwardValidation

          public boolean isForwardValidation()

    - #### setForwardValidation

          public void setForwardValidation(boolean forwardValidation)

    - #### getContent

          public String getContent()

    - #### setContent

          public void setContent(String content)

    - #### getName

          public String getName()

    - #### setName

          public void setName(String name)

    - #### getErrorMessage

          public String getErrorMessage()

    - #### setErrorMessage

          public void setErrorMessage(String errorMessage)

    - #### getMandatoryMessage

          public String getMandatoryMessage()

    - #### setMandatoryMessage

          public void setMandatoryMessage(String mandatoryMessage)

    - #### getErrorElementId

          public String getErrorElementId()

    - #### setErrorElementId

          public void setErrorElementId(String errorElementId)

    - #### getWrappedFormElement

          protected FormElement getWrappedFormElement()

    - #### release

          public void release()

      Specified by:
        `release` in interface `javax.servlet.jsp.tagext.Tag`
      Overrides:
        `release` in class `javax.servlet.jsp.tagext.BodyTagSupport`

    - #### getFormData

          public FormData getFormData()

    - #### getFormGroup

          public FormGroup getFormGroup()

    - #### getDesc

          public String getDesc()

    - #### setDesc

          public void setDesc(String desc)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.