Class SelectTag

java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
com.randomnoun.common.webapp.taglib.StandardHtmlTag
com.randomnoun.common.webapp.taglib.SelectTag
All Implemented Interfaces:
jakarta.servlet.jsp.tagext.IterationTag, jakarta.servlet.jsp.tagext.JspTag, jakarta.servlet.jsp.tagext.Tag, Serializable

public class SelectTag extends StandardHtmlTag
Render a dynamic HTML SELECT tag using information from a structured list.

This class is intended to be used in a JSP 2.0 container, i.e. EL expressions will have already been evaluated by the container before they reach this class.

Attributes defined for this tag (in common.tld) are:

  • name - the NAME element of the generated SELECT tag.
  • value - the current value of the SELECT tag.
  • data - a reference to a structured list containing both display and value columns, or a list of Strings. An empty list can be forced by setting an empty data attribute.
  • valueColumn - the name of the column in the list to use to populate OPTION values
  • displayColumn - the name of the column in the list to use to populate OPTION display text (will default to valueColumn if left blank)
  • firstOption - specifies a display value for the first option for a list; this option corresponds to a null value. Used to generate options like '(please select...)' at the top of a select box.
  • bundle - the resource bundle used to internationalise display column text
  • bundleFormat - a MessageFormat used to convert a value into a bundle key
Only one of 'value' and 'valueFromRequest' can be set.

Additional attributes that are passed directly through to HTML: See StandardHtmlTag for a list of additional attributes which will be directly generated as HTML.

See Also:
  • Constructor Details

  • Method Details

    • setName

      public void setName(String name)
      Sets the name of the SELECT tag.
      Parameters:
      value - the name of the SELECT tag.
    • getName

      public String getName()
      Retrieves the name of the SELECT tag.
      Returns:
      the name of the SELECT tag.
    • setValue

      public void setValue(String value)
      Sets the current value of the SELECT tag.
      Parameters:
      value - the current value of the SELECT tag.
    • getValue

      public String getValue()
      Retrieves the current value of the SELECT tag.
      Returns:
      the current value of the SELECT tag.
    • setData

      public void setData(Object data)
      Sets the structured list used to populate the SELECT tag.
      Parameters:
      value - the structured list used to populate the SELECT tag.
    • getData

      public Object getData()
      Retrieves the structured list used to populate the SELECT tag.
      Returns:
      the structured list used to populate the SELECT tag.
    • setBundle

      public void setBundle(String bundleString)
      Sets the resource bundle used to internationalise display column text
      Parameters:
      value - the resource bundle used to internationalise display column text
    • getBundle

      public String getBundle()
      Retrieves the resource bundle used to internationalise display column text
      Returns:
      the resource bundle used to internationalise display column text
    • setBundleFormat

      public void setBundleFormat(String bundleFormat)
      Sets how the resource bundle will be used to retrieve i18n text
      Parameters:
      value - how the resource bundle will be used to retrieve i18n text
    • bundlePattern

      Retrieves how the resource bundle will be used to retrieve i18n text
      Returns:
      how the resource bundle will be used to retrieve i18n text
    • setValueColumn

      public void setValueColumn(String valueColumn)
      Sets the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
      Parameters:
      value - the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
    • getValueColumn

      Retrieves the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
      Returns:
      the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
    • setDisplayColumn

      public void setDisplayColumn(String displayColumn)
      Sets the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
      Parameters:
      value - the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.
    • getDisplayColumn

      Retrieves the column name in the 'data' structured list used to represent OPTION display text in the generated SELECT HTML.
      Returns:
      the column name in the 'data' structured list used to represent OPTION display text in the generated SELECT HTML.
    • setFirstOption

      public void setFirstOption(String firstOption)
      Sets the display text for a first OPTION of the SELECT tag.
      Parameters:
      value - the display text for a first OPTION of the SELECT tag.
    • getFirstOption

      Retrieves the display text for a first OPTION of the SELECT tag.
      Returns:
      the display text for a first OPTION of the SELECT tag.
    • setFormatDate

      public void setFormatDate(String formatDate)
      Sets the date pattern to use to format Date objects
      Parameters:
      value - the date pattern to use to format Date objects
    • getFormatDate

      Retrieves the date pattern to use to format Date objects
      Returns:
      the date pattern to use to format Date objects
    • setMultiple

      public void setMultiple(String multiple)
      Sets the name of the multiple attribute.
      Parameters:
      value - the name of the multiple attribute.
    • getMultiple

      public String getMultiple()
      Retrieves the name of the multiple attribute.
      Returns:
      the name of the multiple attribute.
    • doStartTag

      public int doStartTag() throws jakarta.servlet.jsp.JspException
      Start custom taglibrary processing. Sets internal private variables based on HttpSession values and defaults, and emits the generating HTML. The body of this tag will not be evaluated, as declared in the the .tld file.
      Specified by:
      doStartTag in interface jakarta.servlet.jsp.tagext.Tag
      Overrides:
      doStartTag in class jakarta.servlet.jsp.tagext.TagSupport
      Returns:
      This method always returns TagSupport.SKIP_BODY, as required by the JSP Taglib specification for empty tags
      Throws:
      jakarta.servlet.jsp.JspException
    • doEndTag

      public int doEndTag()
      End of custom tag library processing. This method performs no work.
      Specified by:
      doEndTag in interface jakarta.servlet.jsp.tagext.Tag
      Overrides:
      doEndTag in class jakarta.servlet.jsp.tagext.TagSupport
      Returns:
      This tag always returns TagSupport.SKIP_BODY .
    • getSelectOptions

      public static List getSelectOptions(ResourceBundle bundle, String prefix, String options)
      Return a localised list for use in a mm:select tag. This function returns a list of Maps, each element of which is a single option in the select tag. The map contains two attributes: 'text' and 'value', containing the internationalised and non-internationalised versions of each option. Note that some select boxes are not internationalised (e.g. 'selectTop').
      Parameters:
      bundle - The bundle to retrieve localisation information form.
      prefix - A prefix used to return information from the bundle
      options - A comma-separated list of option values
      Returns:
      A List as documented above