net.sf.chainedoptions.support
Class OptionalRefreshChainedOption

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

public class OptionalRefreshChainedOption
extends java.lang.Object
implements ChainedOption, org.springframework.beans.factory.InitializingBean

Decorator to provide support for optional refresh on the target ChainedOption. The specified refreshProperty property on the target command is inspected prior to forwarding any retrieveOptions and updateValue calls to the target ChainedOption. If this property is false an empty List will be returned by retrieveOptions, and updateValue will do nothing.

Such a behavior is useful for example when a click in a checkbox should change another field between a selectbox (for fixed values) and a textbox (for free text search).

Author:
Mattias Arthursson

Constructor Summary
OptionalRefreshChainedOption()
           
 
Method Summary
 void afterPropertiesSet()
           
 java.lang.String getOptionsKey()
          Forward the call to the target ChainedOption
 ChainedOptionStrategy getStrategy(java.lang.Object command)
          Forward the call to the target ChainedOption.
 java.util.List retrieveOptions(java.lang.Object command, java.lang.Object context)
          Forward the retrieveOptions call to the target ChainedOption if the refreshProperty property on the target command is true.
 void setChainedOption(ChainedOption chainedOption)
          Set the ChainedOption that this decorator wraps.
 void setRefreshProperty(java.lang.String refreshProperty)
          Set the name of the property to inspect on the command object to determine whether retrieveOptions(Object, Object)and updateValue(Object, List, Object)should forward the call to the target ChainedOption.
 void updateValue(java.lang.Object command, java.util.List options, java.lang.Object context)
          Forward the updateValue call to the target ChainedOptionrefreshProperty property on the target command is true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OptionalRefreshChainedOption

public OptionalRefreshChainedOption()
Method Detail

retrieveOptions

public java.util.List retrieveOptions(java.lang.Object command,
                                      java.lang.Object context)
Forward the retrieveOptions call to the target ChainedOption if the refreshProperty property on the target command is true.

Specified by:
retrieveOptions in interface ChainedOption
Parameters:
command - Command object to use when extracting values that the ChainedOption depends on.
context - may contain any context that might be interesting for retreiving valid options. E.g. a HttpServletRequest object can be supplied as context for a Strategy to perform filtering based on user access.
Returns:
the result of retrieveOptions on the target ChainedOption if we are to forward, an empty LinkedList otherwise.
See Also:
ChainedOption.retrieveOptions(java.lang.Object, java.lang.Object)

updateValue

public void updateValue(java.lang.Object command,
                        java.util.List options,
                        java.lang.Object context)
Forward the updateValue call to the target ChainedOptionrefreshProperty property on the target command is true.

Specified by:
updateValue in interface ChainedOption
Parameters:
command - The command object that may be updated.
options - A list of LabelValueBeanobjects to choose from.
context - may contain any context that might be interesting for retreiving valid options. E.g. a HttpServletRequest object can be supplied as context for a Strategy to perform filtering based on user access.
See Also:
ChainedOption.updateValue(java.lang.Object, java.util.List, java.lang.Object)

getOptionsKey

public java.lang.String getOptionsKey()
Forward the call to the target ChainedOption

Specified by:
getOptionsKey in interface ChainedOption
Returns:
the result from the target ChainedOption.

setChainedOption

public void setChainedOption(ChainedOption chainedOption)
Set the ChainedOption that this decorator wraps.

Parameters:
chainedOption - the ChainedOption to forward calls to.

setRefreshProperty

public void setRefreshProperty(java.lang.String refreshProperty)
Set the name of the property to inspect on the command object to determine whether retrieveOptions(Object, Object)and updateValue(Object, List, Object)should forward the call to the target ChainedOption.

Parameters:
refreshProperty - name of the property.

afterPropertiesSet

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

getStrategy

public ChainedOptionStrategy getStrategy(java.lang.Object command)
Forward the call to the target ChainedOption.

Specified by:
getStrategy in interface ChainedOption
Parameters:
command - the command to operate on.
Returns:
the value returned from the target ChainedOption.


Copyright ? 2005. All Rights Reserved.