com.taggercat.tags
Class HTMLListMenuOptionsListTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by com.taggercat.tags.HTMLListMenuOptionsListTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class HTMLListMenuOptionsListTag
extends javax.servlet.jsp.tagext.TagSupport

This tag creates HTML select options that are sourced from a List or a Map of objects. Although it can be used with any object type, it will probably be mostly commonly used with Entities and FKs on Entities.

Even though this tag is very similar to the ListOptionListTag, it is different in that it allows you to set object references, and not deal exclusively with string values.

The intended use of this tag is similar to the functionality of Code Tables, where you need to set a foreign key, or other object reference, on an entity using a Menu List element. But, unlike code tables, the source of FK entities, or other objects, can come from an arbitrary List or Map.

Items in the List or Map must implement the OptionItem interface.

Presenting the list as HTML option tags is only half the story though. Upon a submit, we usually need to set the corresponding selected item from the Collection or Map on the parent entity.

To accomplish that, this tag also gets its parent HTMLListMenu tag to generate an extra hidden form element.
That hidden form element submits the TC EL Expression where the source options can be found; such as: session.cutomerAddressOptions.

Of course, the source of the Map or Collection must also be available, and resolve to the same collection upon the submit. Therefore, the listOptions and the sourceValuesExpr attributes will commonly be nearly the same. The difference being that listOptions attribute would be an JSP EL that is evaluated at page response time, and sourceValuesExpr attribute would be the same literal expression; but without the $[....} delimiters.

See Also:
OptionItem, ColorCodedOptionItem, ListOptionListTag, DataSourceOptionListTag, Serialized Form
 

Field Summary
 
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
HTMLListMenuOptionsListTag()
           
 
Method Summary
 int doEndTag()
          Resets the tags internal state.
 int doStartTag()
          Creates and the option list tags and sends them to the page.
 java.lang.String getDsn()
          Gets the sources data source name.
 java.lang.String getField()
           
 java.util.Collection<OptionItem> getListOptions()
           
 java.util.Map<java.lang.String,OptionItem> getMapOptions()
           
 java.lang.String getMissingItemStyleclass()
           
 java.lang.Object getSelected()
          Gets the selected item.
 java.lang.String getSelectedStyleclass()
          Gets the CSS style class to be used to selected items in the option list.
 java.lang.String getSourceVar()
           
 java.lang.String getStyleclass()
          Gets the CSS style class to be used to items in the option list.
 boolean isAddEmptyItem()
           
 void setAddEmptyItem(boolean addEmptyItem)
           
 void setDsn(java.lang.String dsn)
          Set the name of the data source this field to test as a boolean ( optional ).
 void setEmptyItem(boolean emptyItem)
          Set to true to add an empty item to the option list.
 void setField(java.lang.String field)
          Sets the field name attribute ( optional ).
 void setListOptions(java.util.Collection<OptionItem> listOptions)
           
 void setMapOptions(java.util.Map<java.lang.String,OptionItem> mapOptions)
           
 void setMissingItemStyleclass(java.lang.String missingItemStyleclass)
          Sets the CSS style class to be used to display a missing, and selected items in the option list.
 void setSelected(java.lang.Object selected)
           
 void setSelected(java.lang.String selected)
          Sets the selected attribute.
 void setSelectedStyleclass(java.lang.String selectedStyleclass)
          Sets the CSS style class to be used to selected items in the option list.
 void setSourceVar(java.lang.String sourceVar)
           
 void setStyleclass(java.lang.String styleclass)
          Sets the CSS style class to be used to items in the option list.
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLListMenuOptionsListTag

public HTMLListMenuOptionsListTag()
Method Detail

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Resets the tags internal state.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException
Returns:
EVAL_PAGE

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Creates and the option list tags and sends them to the page.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException
Returns:
SKIP_BODY

getDsn

public java.lang.String getDsn()
Gets the sources data source name.

Returns:
the source data source

getSelected

public java.lang.Object getSelected()
Gets the selected item.

Returns:
the selected item

getSelectedStyleclass

public java.lang.String getSelectedStyleclass()
Gets the CSS style class to be used to selected items in the option list.

Returns:
the CSS style class to be used to selected items in the option list.

getStyleclass

public java.lang.String getStyleclass()
Gets the CSS style class to be used to items in the option list.

Returns:
the CSS style class to be used to items in the option list

setEmptyItem

public void setEmptyItem(boolean emptyItem)
Set to true to add an empty item to the option list.

Parameters:
emptyItem - The new codeField value

setDsn

public void setDsn(java.lang.String dsn)
Set the name of the data source this field to test as a boolean ( optional ).

Parameters:
dsn - the new dsn fieldValue

setField

public void setField(java.lang.String field)
Sets the field name attribute ( optional ).

Parameters:
field - the new field fieldValue

setSelected

public void setSelected(java.lang.String selected)
Sets the selected attribute. This is a value that is used to locate the current item in the option list. If a selected value is not specified, then the field value from the current tcEntity in the specified DSN is used.

Parameters:
selected - The new selected value

setSelectedStyleclass

public void setSelectedStyleclass(java.lang.String selectedStyleclass)
Sets the CSS style class to be used to selected items in the option list.

Parameters:
selectedStyleclass - the CSS style class to be used to selected items in the option list.

setStyleclass

public void setStyleclass(java.lang.String styleclass)
Sets the CSS style class to be used to items in the option list.

Parameters:
styleclass - the CSS style class to be used to items in the option list

setMissingItemStyleclass

public void setMissingItemStyleclass(java.lang.String missingItemStyleclass)
Sets the CSS style class to be used to display a missing, and selected items in the option list. Where the missing item is defined as on that exists in the child data source but not in the list of options provided

Parameters:
missingItemStyleclass - the CSS style class to be used to missing items in the option list.

getSourceVar

public java.lang.String getSourceVar()

setSourceVar

public void setSourceVar(java.lang.String sourceVar)

isAddEmptyItem

public boolean isAddEmptyItem()

setAddEmptyItem

public void setAddEmptyItem(boolean addEmptyItem)

getListOptions

public java.util.Collection<OptionItem> getListOptions()

setListOptions

public void setListOptions(java.util.Collection<OptionItem> listOptions)

getMapOptions

public java.util.Map<java.lang.String,OptionItem> getMapOptions()

setMapOptions

public void setMapOptions(java.util.Map<java.lang.String,OptionItem> mapOptions)

getMissingItemStyleclass

public java.lang.String getMissingItemStyleclass()

getField

public java.lang.String getField()

setSelected

public void setSelected(java.lang.Object selected)