org.pm4j.core.pm.impl
Class PmElementBase

java.lang.Object
  extended by org.pm4j.core.pm.impl.PmObjectBase
      extended by org.pm4j.core.pm.impl.PmDataInputBase
          extended by org.pm4j.core.pm.impl.PmElementBase
All Implemented Interfaces:
java.lang.Comparable<PmObject>, PmDataInput, PmElement, PmObject, PmTreeNode
Direct Known Subclasses:
PmBeanBase, PmConversationImpl, PmElementImpl

public abstract class PmElementBase
extends PmDataInputBase
implements PmElement


Nested Class Summary
 
Nested classes/interfaces inherited from class org.pm4j.core.pm.impl.PmObjectBase
PmObjectBase.MetaData, PmObjectBase.NameBuilder, PmObjectBase.NameBuilderAbsoluteName, PmObjectBase.NameBuilderShortName, PmObjectBase.NameBuilderTitle
 
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
PmElementBase()
          Constructor for dependency injection frameworks that are not able to use constructors (e.g.
PmElementBase(PmObject pmParent)
           
 
Method Summary
 void accept(PmVisitor visitor)
           
protected  void clearCachedPmValues(java.util.Set<PmCacheApi.CacheKind> cacheSet)
          Clears cached content (if there was something cached).
Causes a reload of the content with the next request.
protected
<T extends java.lang.annotation.Annotation>
void
findAnnotationsInPmHierarchy(java.lang.Class<T> annotationClass, java.util.Collection<T> foundAnnotations)
          Searches an annotation within the attribute-element-session hierarchy.
 PmObject getNodeDetailsPm()
          This method supports master-detail views.
 PmAttr<?> getPmAttribute(java.lang.String attrName)
           
 java.util.List<PmAttr<?>> getPmAttributes()
           
 java.util.List<PmTreeNode> getPmChildNodes()
           
protected  java.util.List<? extends PmTreeNode> getPmChildNodesImpl()
          The implementation of child node generation.
The default implementation provides all attributes that implement the PmTreeNode interface.
 PmConversation getPmConversation()
          Optimization: Cached session navigation.
 java.io.Serializable getPmKey()
          The default implementation provides a unique identifier for this model.
protected  boolean isPmReadonlyImpl()
          Sub classes may implement their specific read-only definition here.
 boolean isPmTreeLeaf()
          The default implementation returns true if there is no child.
protected  boolean isValidatingOnSetPmValue()
          Defines if the attribute validation should be executed on each attribute value set operation.
protected  PmObjectBase.MetaData makeMetaData()
          Gets called when the meta data instance for this presentation model is not yet available (first call within the VM live time).
 
Methods inherited from class org.pm4j.core.pm.impl.PmDataInputBase
commitBufferedPmChanges, isBufferedPmValueMode, isPmValueChanged, pmValidate, resetPmValues, rollbackBufferedPmChanges
 
Methods inherited from class org.pm4j.core.pm.impl.PmObjectBase
addToPmComposite, canSetPmTitle, clearPmInvalidValues, compareTo, ensurePmMetaDataInitialization, getPmConversationImpl, getPmIconPath, getPmMetaData, getPmMetaDataWithoutPmInitCall, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmResKey, getPmResKeyBase, getPmResLoaderCtxtClasses, getPmShortTitle, getPmStyleClasses, getPmStyleClassesImpl, getPmTitle, getPmTitleDef, getPmTitleImpl, getPmTooltip, getPmTooltipImpl, getVisiblePmCommands, getVisiblePmCommands, initMetaData, isMetaDataInitialized, isPmEnabled, isPmEnabledImpl, isPmReadonly, isPmValid, isPmVisible, isPmVisibleImpl, 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.PmDataInput
commitBufferedPmChanges, isBufferedPmValueMode, isPmValueChanged, pmValidate, resetPmValues, rollbackBufferedPmChanges
 
Methods inherited from interface org.pm4j.core.pm.PmObject
canSetPmTitle, compareTo, getPmIconPath, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmShortTitle, getPmStyleClasses, getPmTitle, getPmTooltip, isPmEnabled, isPmReadonly, isPmValid, isPmVisible, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible
 

Constructor Detail

PmElementBase

public PmElementBase()
Constructor for dependency injection frameworks that are not able to use constructors (e.g. JSF).
Please make sure that the method PmObjectBase.setPmParent(PmObject) is called before this object will be used!


PmElementBase

public PmElementBase(PmObject pmParent)
Parameters:
pmParent - The context, this pm was created in. E.g. a session, a command, a list field.
Method Detail

getPmKey

public java.io.Serializable getPmKey()
The default implementation provides a unique identifier for this model.

Specified by:
getPmKey in interface PmElement
Returns:
A key that identifies the element within the session.

accept

public void accept(PmVisitor visitor)
Specified by:
accept in interface PmObject
Overrides:
accept in class PmObjectBase
Parameters:
visitor - A visitor to call back.

getPmAttributes

public java.util.List<PmAttr<?>> getPmAttributes()
Specified by:
getPmAttributes in interface PmElement
Returns:
The set of attributes.

getPmAttribute

public final PmAttr<?> getPmAttribute(java.lang.String attrName)
Specified by:
getPmAttribute in interface PmElement
Parameters:
attrName - Name of the requested attribute.
Returns:
The matching attribute instance. Never null.

clearCachedPmValues

protected void clearCachedPmValues(java.util.Set<PmCacheApi.CacheKind> cacheSet)
Description copied from class: PmObjectBase
Clears cached content (if there was something cached).
Causes a reload of the content with the next request.

Overrides:
clearCachedPmValues in class PmObjectBase

isPmReadonlyImpl

protected boolean isPmReadonlyImpl()
Description copied from class: PmObjectBase
Sub classes may implement their specific read-only definition here.

Overrides:
isPmReadonlyImpl in class PmObjectBase
Returns:
true if the PM is in read-only state.

isValidatingOnSetPmValue

protected boolean isValidatingOnSetPmValue()
Defines if the attribute validation should be executed on each attribute value set operation. - That's that default setting.

It may be useful to switch that behavior off and to postpone validation till command execution.

The default implementation returns false.

Returns:
true when attribute validation should be done on each set operation.

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.

getPmChildNodes

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

getPmChildNodesImpl

protected java.util.List<? extends PmTreeNode> getPmChildNodesImpl()
The implementation of child node generation.
The default implementation provides all attributes that implement the PmTreeNode interface.

Subclasses may provide their own logic by overriding this method.

The result of this method will be cached by the method getPmChildNodes(). You may call #clearCachedPmValues() to clear this cache.

Returns:
The set of child nodes.

isPmTreeLeaf

public boolean isPmTreeLeaf()
The default implementation returns true if there is no child. Otherwise false.

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

getPmConversation

public PmConversation getPmConversation()
Optimization: Cached session navigation.

Specified by:
getPmConversation in interface PmObject
Overrides:
getPmConversation in class PmObjectBase
Returns:
The conversation context of this model element. Never null.

makeMetaData

protected PmObjectBase.MetaData makeMetaData()
Description copied from class: PmObjectBase
Gets called when the meta data instance for this presentation model is not yet available (first call within the VM live time).

Subclasses that provide more specific meta data should override this method to provide their meta data information container.

Specified by:
makeMetaData in class PmObjectBase
Returns:
A static data container for this presentation model.

findAnnotationsInPmHierarchy

protected <T extends java.lang.annotation.Annotation> void findAnnotationsInPmHierarchy(java.lang.Class<T> annotationClass,
                                                                                        java.util.Collection<T> foundAnnotations)
Description copied from class: PmObjectBase
Searches an annotation within the attribute-element-session hierarchy. Adds all found annotations to the given collection. Adds nothing when no annotation was found in the hierarchy.

Overrides:
findAnnotationsInPmHierarchy in class PmObjectBase
Parameters:
annotationClass - The annotation to find.
foundAnnotations - The set to add the found annotations to. The lowest level annotation (e.g. bound to an attribute) is at the first position. The highest level annotation (e.g. bound to the root session) is at the last position.