org.pm4j.core.pm.impl
Class PmAttrPmListImpl<T_ITEM_PM extends PmBean<T_BEAN>,T_BEAN>

java.lang.Object
  extended by org.pm4j.core.pm.impl.PmObjectBase
      extended by org.pm4j.core.pm.impl.PmAttrBase<java.util.List<T_ITEM_PM>,java.util.Collection<T_BEAN>>
          extended by org.pm4j.core.pm.impl.PmAttrPmListImpl<T_ITEM_PM,T_BEAN>
Type Parameters:
T_ITEM_PM -
T_BEAN -
All Implemented Interfaces:
java.lang.Comparable<PmObject>, PmAttr<java.util.List<T_ITEM_PM>>, PmAttrPmList<T_ITEM_PM>, PmDataInput, PmObject, PmTreeNode

public class PmAttrPmListImpl<T_ITEM_PM extends PmBean<T_BEAN>,T_BEAN>
extends PmAttrBase<java.util.List<T_ITEM_PM>,java.util.Collection<T_BEAN>>
implements PmAttrPmList<T_ITEM_PM>

TODOC:

Author:
olaf boede

Nested Class Summary
protected static class PmAttrPmListImpl.MetaData
           
 
Nested classes/interfaces inherited from class org.pm4j.core.pm.impl.PmObjectBase
PmObjectBase.NameBuilder, PmObjectBase.NameBuilderAbsoluteName, PmObjectBase.NameBuilderShortName, PmObjectBase.NameBuilderTitle
 
Nested classes/interfaces inherited from interface org.pm4j.core.pm.PmAttr
PmAttr.Converter<T>
 
Field Summary
 
Fields inherited from class org.pm4j.core.pm.impl.PmObjectBase
pmCacheLog
 
Fields inherited from interface org.pm4j.core.pm.PmObject
STYLE_CLASS_DISABLED, STYLE_CLASS_ERROR, STYLE_CLASS_INFO, STYLE_CLASS_REQUIRED, STYLE_CLASS_WARN
 
Constructor Summary
PmAttrPmListImpl(PmObject pmParent)
           
 
Method Summary
 void add(T_ITEM_PM pmElement)
           
 java.util.List<T_ITEM_PM> convertBackingValueToPmValue(java.util.Collection<T_BEAN> beanList)
           
 java.util.Collection<T_BEAN> convertPmValueToBackingValue(java.util.List<T_ITEM_PM> rawPmAttrValue)
           
 T_ITEM_PM getFirstItem()
           
 boolean getHasVisibleItems()
          For lists that may contain invisible items.
 T_ITEM_PM getLastItem()
           
 PmObject getNodeDetailsPm()
          This method supports master-detail views.
protected  PmObject getNodeDetailsPmImpl()
           
 PmOptionCfg.NullOption getNullOptionDefault()
          Provides the attribute type specific default definition, if an option set should contain a null option definition or not.
 java.util.List<PmTreeNode> getPmChildNodes()
           
 int getSize()
           
 java.util.List<T_ITEM_PM> getValueAsList()
          An explicte list value signature.
 java.util.List<T_ITEM_PM> getValueSubset(int fromIdx, int numItems)
          Provides a subset of the whole item set.
protected  void initMetaData(PmObjectBase.MetaData metaData)
           
protected  boolean isEmptyValue(java.util.List<T_ITEM_PM> value)
          Checks the attribute type specific null or empty value condition.
 boolean isPmTreeLeaf()
          The default implementation returns false because the children of a list attribute are usually displayed as tree child nodes.
protected  java.util.Collection<T_BEAN> makeBeanCollection()
          The collection to put the values to may be very different.
protected  PmAttrBase.MetaData makeMetaData()
          It's abstract because specific attribute types have to create their specific meta data.
 void pmValidate()
          In addition to standard checks (required check) it forwards the validation to the list items provided by the parameter.
 boolean remove(T_ITEM_PM pmElement)
           
 void setValueAsList(java.util.List<T_ITEM_PM> value)
           
 
Methods inherited from class org.pm4j.core.pm.impl.PmAttrBase
accept, clearCachedPmValues, clearPmInvalidValues, commitBufferedPmChanges, compareTo, equalValues, getBackingValue, getBackingValueImpl, getConverter, getDefaultValue, getDefaultValueImpl, getFormatDefaultResKey, getFormatString, getMaxLen, getMinLen, getOptionSet, getOptionSetImpl, getOptionValues, getPmParentElement, getPmStyleClassesImpl, getUncachedValidValue, getValue, getValueAsString, getValueImpl, getValueLocalized, initMetaDataBeanConstraint, isBufferedPmValueMode, isPmEnabledImpl, isPmReadonlyImpl, isPmValueChanged, isPmVisibleImpl, isRequired, isSupportingAsStringValues, isValidatingOnSetPmValue, makeOptionSetDef, resetPmValues, rollbackBufferedPmChanges, setBackingValue, setBackingValueImpl, setPmValueChanged, setValue, setValueAsString, setValueImpl, validate
 
Methods inherited from class org.pm4j.core.pm.impl.PmObjectBase
addToPmComposite, canSetPmTitle, ensurePmMetaDataInitialization, findAnnotationsInPmHierarchy, getPmConversation, getPmConversationImpl, getPmIconPath, getPmMetaData, getPmMetaDataWithoutPmInitCall, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmResKey, getPmResKeyBase, getPmResLoaderCtxtClasses, getPmShortTitle, getPmStyleClasses, getPmTitle, getPmTitleDef, getPmTitleImpl, getPmTooltip, getPmTooltipImpl, getVisiblePmCommands, getVisiblePmCommands, isMetaDataInitialized, isPmEnabled, isPmReadonly, isPmValid, isPmVisible, onPmChildStateChange, onPmInit, onPmValueChange, readCacheStrategy, removePmChild, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.pm4j.core.pm.PmAttr
getFormatString, getMaxLen, getMinLen, getOptionSet, getValue, getValueAsString, getValueLocalized, isPmValueChanged, isRequired, resetPmValues, setPmValueChanged, setValue, setValueAsString
 
Methods inherited from interface org.pm4j.core.pm.PmDataInput
commitBufferedPmChanges, isBufferedPmValueMode, rollbackBufferedPmChanges
 
Methods inherited from interface org.pm4j.core.pm.PmObject
accept, canSetPmTitle, compareTo, getPmConversation, getPmIconPath, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmShortTitle, getPmStyleClasses, getPmTitle, getPmTooltip, isPmEnabled, isPmReadonly, isPmValid, isPmVisible, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible
 

Constructor Detail

PmAttrPmListImpl

public PmAttrPmListImpl(PmObject pmParent)
Method Detail

add

public void add(T_ITEM_PM pmElement)
Specified by:
add in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>

remove

public boolean remove(T_ITEM_PM pmElement)
Specified by:
remove in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>

getValueAsList

public final java.util.List<T_ITEM_PM> getValueAsList()
Description copied from interface: PmAttrPmList
An explicte list value signature. This signature is required for reflection based frameworks that analyze the method signature for their data binding (e.g. JSF). Such analysis for PmAttr.getValue() will just find out that the method returns an object. The same analysis perfomed on this method will provide the result that the returned value is a list...

Specified by:
getValueAsList in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Returns:
The list value.

setValueAsList

public final void setValueAsList(java.util.List<T_ITEM_PM> value)
Specified by:
setValueAsList in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Parameters:
value - The new list value.
See Also:
PmAttrPmList.getValueAsList()

getValueSubset

public java.util.List<T_ITEM_PM> getValueSubset(int fromIdx,
                                                int numItems)
Description copied from interface: PmAttrPmList
Provides a subset of the whole item set.

Specified by:
getValueSubset in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Parameters:
fromIdx - Index of the first item to get.
numItems - The maximal number of items to get.
Returns:
The subset. May be empty but never null

getFirstItem

public T_ITEM_PM getFirstItem()
Specified by:
getFirstItem in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Returns:
The first list item. null in case of an empty list.

getLastItem

public T_ITEM_PM getLastItem()
Specified by:
getLastItem in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Returns:
The last list item. null in case of an empty list.

getSize

public int getSize()
Specified by:
getSize in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Returns:
number of list items provided by #{link PmAttr.getValue().

getHasVisibleItems

public boolean getHasVisibleItems()
Description copied from interface: PmAttrPmList
For lists that may contain invisible items.

Used for very special JSF components (such as t:dataList) which require at least a single dummy element to be able to be refreshed by ajax requests...

Specified by:
getHasVisibleItems in interface PmAttrPmList<T_ITEM_PM extends PmBean<T_BEAN>>
Returns:
true if at least a single list item is visible.

isEmptyValue

protected boolean isEmptyValue(java.util.List<T_ITEM_PM> value)
Description copied from class: PmAttrBase
Checks the attribute type specific null or empty value condition.

Overrides:
isEmptyValue in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>
Returns:
true when the value is a null or empty value equivalent.

getNullOptionDefault

public PmOptionCfg.NullOption getNullOptionDefault()
Description copied from class: PmAttrBase
Provides the attribute type specific default definition, if an option set should contain a null option definition or not.

Usualy non-list attributes provide the default PmOptionCfg.NullOption#FOR_OPTIONAL_ATTR and list attributes PmOptionCfg.NullOption#NO.

Overrides:
getNullOptionDefault in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>
Returns:
The attribute type specific null-option generation default value.

getNodeDetailsPm

public PmObject getNodeDetailsPm()
Description copied from interface: PmTreeNode
This method supports master-detail views.

Specified by:
getNodeDetailsPm in interface PmTreeNode
Returns:
The (optional) details PM to present in a details view.

getNodeDetailsPmImpl

protected PmObject getNodeDetailsPmImpl()

getPmChildNodes

public java.util.List<PmTreeNode> getPmChildNodes()
Specified by:
getPmChildNodes in interface PmTreeNode
Returns:
The set of sub-nodes to display for this item.

isPmTreeLeaf

public boolean isPmTreeLeaf()
The default implementation returns false because the children of a list attribute are usually displayed as tree child nodes.

Specified by:
isPmTreeLeaf in interface PmTreeNode
Returns:
true if this instance should be presented as a tree leaf node.

makeBeanCollection

protected java.util.Collection<T_BEAN> makeBeanCollection()
The collection to put the values to may be very different. Some beans expect a Set, others a List.

The default implementation provides an ArrayList.

Returns:
A new empty collection.

convertBackingValueToPmValue

public java.util.List<T_ITEM_PM> convertBackingValueToPmValue(java.util.Collection<T_BEAN> beanList)
Overrides:
convertBackingValueToPmValue in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>

convertPmValueToBackingValue

public java.util.Collection<T_BEAN> convertPmValueToBackingValue(java.util.List<T_ITEM_PM> rawPmAttrValue)
Overrides:
convertPmValueToBackingValue in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>

pmValidate

public void pmValidate()
In addition to standard checks (required check) it forwards the validation to the list items provided by the parameter.

Specified by:
pmValidate in interface PmDataInput
Overrides:
pmValidate in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>

makeMetaData

protected PmAttrBase.MetaData makeMetaData()
Description copied from class: PmAttrBase
It's abstract because specific attribute types have to create their specific meta data.

Specified by:
makeMetaData in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>
Returns:
A static data container for this presentation model.

initMetaData

protected void initMetaData(PmObjectBase.MetaData metaData)
Overrides:
initMetaData in class PmAttrBase<java.util.List<T_ITEM_PM extends PmBean<T_BEAN>>,java.util.Collection<T_BEAN>>