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
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
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:
-
Field Summary
Fields inherited from class com.randomnoun.common.webapp.taglib.StandardHtmlTag
attributes, extraAttributes
Fields inherited from class jakarta.servlet.jsp.tagext.TagSupport
id, pageContext
Fields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
Fields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves how the resource bundle will be used to retrieve i18n textint
doEndTag()
End of custom tag library processing.int
Start custom taglibrary processing.Retrieves the resource bundle used to internationalise display column textgetData()
Retrieves the structured list used to populate the SELECT tag.Retrieves the column name in the 'data' structured list used to represent OPTION display text in the generated SELECT HTML.Retrieves the display text for a first OPTION of the SELECT tag.Retrieves the date pattern to use to format Date objectsRetrieves the name of the multiple attribute.getName()
Retrieves the name of the SELECT tag.static List
getSelectOptions
(ResourceBundle bundle, String prefix, String options) Return a localised list for use in a mm:select tag.getValue()
Retrieves the current value of the SELECT tag.Retrieves the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.void
Sets the resource bundle used to internationalise display column textvoid
setBundleFormat
(String bundleFormat) Sets how the resource bundle will be used to retrieve i18n textvoid
Sets the structured list used to populate the SELECT tag.void
setDisplayColumn
(String displayColumn) Sets the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.void
setFirstOption
(String firstOption) Sets the display text for a first OPTION of the SELECT tag.void
setFormatDate
(String formatDate) Sets the date pattern to use to format Date objectsvoid
setMultiple
(String multiple) Sets the name of the multiple attribute.void
Sets the name of the SELECT tag.void
Sets the current value of the SELECT tag.void
setValueColumn
(String valueColumn) Sets the column name in the 'data' structured list used to represent OPTION values in the generated SELECT HTML.Methods inherited from class com.randomnoun.common.webapp.taglib.StandardHtmlTag
clearAttributes, evaluateAttributes, getAttributes, getAttributeString, getExtraAttributes, setAccessKey, setContenteditable, setDir, setDisabled, setExtraAttributes, setHidefocus, setLang, setLanguage, setMaxlength, setOnactivate, setOnafterupdate, setOnbeforeactvate, setOnbeforecut, setOnbeforedeactivate, setOnbeforeeditfocus, setOnbeforepaste, setOnbeforeupdate, setOnblur, setOnchange, setOnclick, setOncontextmenu, setOncontrolselect, setOncut, setOndblclick, setOndeactivate, setOndrag, setOndragend, setOndragenter, setOndragleave, setOndragover, setOndragstart, setOndrop, setOnerrorupdate, setOnfilterchange, setOnfocus, setOnfocusin, setOnfocusout, setOnhelp, setOnkeydown, setOnkeypress, setOnkeyup, setOnlosecapture, setOnmousedown, setOnmouseenter, setOnmouseleave, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnmousewheel, setOnmove, setOnmoveend, setOnmovestart, setOnpaste, setOnpropertychange, setOnreadystatechange, setOnresize, setOnresizeend, setOnresizestart, setOnselect, setOnselectstart, setOntimeerror, setReadonly, setSize, setStyle, setStyleClass, setTabindex, setTitle, setUnselectable, setWidth
Methods inherited from class jakarta.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
-
Constructor Details
-
SelectTag
public SelectTag()
-
-
Method Details
-
setName
Sets the name of the SELECT tag.- Parameters:
value
- the name of the SELECT tag.
-
getName
Retrieves the name of the SELECT tag.- Returns:
- the name of the SELECT tag.
-
setValue
Sets the current value of the SELECT tag.- Parameters:
value
- the current value of the SELECT tag.
-
getValue
Retrieves the current value of the SELECT tag.- Returns:
- the current value of the SELECT tag.
-
setData
Sets the structured list used to populate the SELECT tag.- Parameters:
value
- the structured list used to populate the SELECT tag.
-
getData
Retrieves the structured list used to populate the SELECT tag.- Returns:
- the structured list used to populate the SELECT tag.
-
setBundle
Sets the resource bundle used to internationalise display column text- Parameters:
value
- the resource bundle used to internationalise display column text
-
getBundle
Retrieves the resource bundle used to internationalise display column text- Returns:
- the resource bundle used to internationalise display column text
-
setBundleFormat
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
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
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
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
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
Sets the name of the multiple attribute.- Parameters:
value
- the name of the multiple attribute.
-
getMultiple
Retrieves the name of the multiple attribute.- Returns:
- the name of the multiple attribute.
-
doStartTag
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 interfacejakarta.servlet.jsp.tagext.Tag
- Overrides:
doStartTag
in classjakarta.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
End of custom tag library processing. This method performs no work.- Specified by:
doEndTag
in interfacejakarta.servlet.jsp.tagext.Tag
- Overrides:
doEndTag
in classjakarta.servlet.jsp.tagext.TagSupport
- Returns:
- This tag always returns TagSupport.SKIP_BODY .
-
getSelectOptions
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 bundleoptions
- A comma-separated list of option values- Returns:
- A List as documented above
-