net.sf.chainedoptions.support
Class ExtraItemsStrategy

java.lang.Object
  extended by net.sf.chainedoptions.support.ExtraItemsStrategy
All Implemented Interfaces:
ChainedOptionStrategy, org.springframework.beans.factory.InitializingBean

public class ExtraItemsStrategy
extends java.lang.Object
implements ChainedOptionStrategy, org.springframework.beans.factory.InitializingBean

Strategy that adds a set of extra items to a given list of options. The set of extra items is configurable. The strategy also provides a default value, which is also configurable.

Author:
Mattias Arthursson, Ulrik Sandberg

Constructor Summary
ExtraItemsStrategy()
           
 
Method Summary
 java.util.List adjustAndSort(java.util.List options, java.lang.Object context)
          Sorts the given list of options.
 void afterPropertiesSet()
           
 LabelValueBean getDefaultItem()
          The default item is the item in the list that should be selected when the list is first displayed.
 java.lang.String getDefaultValue(java.util.List options, java.lang.Object context)
          Provides the default value of the given list of options.
 void setDefaultItem(LabelValueBean defaultItem)
          The default item is the item in the list that should be selected when the list is first displayed.
 void setExtraItems(java.util.List extraItems)
          Extra items are items that signify special values, like ANY, EMPTY, NOCHANGE etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtraItemsStrategy

public ExtraItemsStrategy()
Method Detail

adjustAndSort

public java.util.List adjustAndSort(java.util.List options,
                                    java.lang.Object context)
Description copied from interface: ChainedOptionStrategy
Sorts the given list of options. May also adjust the list of options by adding or removing entries.

Specified by:
adjustAndSort in interface ChainedOptionStrategy
Parameters:
options - List of LabelValueBean objects to adjust and sort.
context - may contain any context that might be interesting for the Strategy for fitering or adding values. E.g. the Request object might be passed as context for the Strategy in order to hide some options depending on user access.
Returns:
A sorted list of LabelValueBean objects.
See Also:
LabelValueBean

getDefaultValue

public java.lang.String getDefaultValue(java.util.List options,
                                        java.lang.Object context)
Description copied from interface: ChainedOptionStrategy
Provides the default value of the given list of options.

Specified by:
getDefaultValue in interface ChainedOptionStrategy
Parameters:
options - List of LabelValueBean objects where the default value must be found.
context - may contain any context that might be interesting for the Strategy to select the default value.
Returns:
A value representing the default value of the given list of options.

setExtraItems

public void setExtraItems(java.util.List extraItems)
Extra items are items that signify special values, like ANY, EMPTY, NOCHANGE etc.

Parameters:
extraItems - The extra items to set as a list of LabelValueBean objects.

getDefaultItem

public LabelValueBean getDefaultItem()
The default item is the item in the list that should be selected when the list is first displayed.

Returns:
Returns the default item as a LabelValueBean.

setDefaultItem

public void setDefaultItem(LabelValueBean defaultItem)
The default item is the item in the list that should be selected when the list is first displayed.

Parameters:
defaultItem - The default item to set as a LabelValueBean.

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception


Copyright ? 2005. All Rights Reserved.