org.pm4j.core.pm
Interface PmAttr<T>

Type Parameters:
T - The attribute value type provided for the view.
All Superinterfaces:
java.lang.Comparable<PmObject>, PmDataInput, PmObject
All Known Subinterfaces:
PmAttrBigDecimal, PmAttrBoolean, PmAttrDate, PmAttrDouble, PmAttrEnum<T_ENUM>, PmAttrInteger, PmAttrList<T>, PmAttrLong, PmAttrNumber<T>, PmAttrPmList<T_ITEM_PM>, PmAttrPmRef<T_REFED_PM>, PmAttrShort, PmAttrString
All Known Implementing Classes:
PmAttrBase, PmAttrBigDecimalImpl, PmAttrBooleanImpl, PmAttrDateBase, PmAttrDateBase.WithFormatTooltip, PmAttrDateImpl, PmAttrDoubleImpl, PmAttrEnumImpl, PmAttrImpl, PmAttrIntegerImpl, PmAttrListImpl, PmAttrListImpl.PmAttrListOfIntegers, PmAttrListImpl.PmAttrListOfLongs, PmAttrListImpl.PmAttrListOfStrings, PmAttrLongImpl, PmAttrNumBase, PmAttrPmListImpl, PmAttrPmRefImpl, PmAttrShortImpl, PmAttrStringImpl, PmTableColImpl.SortOrderAttr

public interface PmAttr<T>
extends PmObject, PmDataInput

Presentation model for attributes. It adds presentation logic aspects for attribute value handling to the base interface PmObject.

An attribute represents a data item that is usually represented as a data entry field on a form.

Details on how to implement application specific attribute logic see PmAttrImpl.

Author:
olaf boede

Nested Class Summary
static interface PmAttr.Converter<T>
          Converts single values between its attribute type representation and String or Serializable representation.
 
Field Summary
 
Fields inherited from interface org.pm4j.core.pm.PmObject
STYLE_CLASS_DISABLED, STYLE_CLASS_ERROR, STYLE_CLASS_INFO, STYLE_CLASS_REQUIRED, STYLE_CLASS_WARN
 
Method Summary
 java.lang.String getFormatString()
          Returns a localized format string for attribute values provided as strings.
The localized format string is based on a resource key which may be defined as follows: You may specify it using the annotation PmAttrCfg.formatResKey(). You may define it within the resource file, using a resource key with a '_format' postfix.
Example: myPm.myNumber_format=#,##0.## For some types such as PmAttrDate and PmAttrDouble you may specify default formats.
(Attribute classes may specify this by implementing getFormatDefaultResKey().)
See: PmAttrDate.RESKEY_DEFAULT_FORMAT_PATTERN and PmAttrDouble.RESKEY_DEFAULT_FORMAT_PATTERN. The resource key gets evaluated in the sequence specified above.
 int getMaxLen()
           
 int getMinLen()
           
 PmOptionSet getOptionSet()
          Provides the set of value options the user may choose from.
 T getValue()
          Provides the actual value of the attribute.
 java.lang.String getValueAsString()
           
 java.lang.String getValueLocalized()
          Some attribute types, such as enums, may provide localized values.
 boolean isPmValueChanged()
          Indicates an attribute value change.
 boolean isRequired()
           
 void resetPmValues()
          Reset the value to null or the optional default value definition.
 void setPmValueChanged(boolean newChangedState)
          Sets an attribute explicitly to a change or unchanged state.
 void setValue(T value)
           
 void setValueAsString(java.lang.String text)
          Sets the value with a string value.
 
Methods inherited from interface org.pm4j.core.pm.PmDataInput
commitBufferedPmChanges, isBufferedPmValueMode, pmValidate, 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
 

Method Detail

getValue

T getValue()
Provides the actual value of the attribute.

For details on how to provide values see: PmAttrBase.getValue()

Returns:
The attribute value.

setValue

void setValue(T value)
Parameters:
value - The new value.

getValueAsString

java.lang.String getValueAsString()
Returns:
The string for the current value.

setValueAsString

void setValueAsString(java.lang.String text)
Sets the value with a string value.

Parameters:
text - The new value as string.

getOptionSet

PmOptionSet getOptionSet()
Provides the set of value options the user may choose from.

Some attributes (e.g. attributes representing enums or references to other objects) usually provide an option set.

Most PM view components use the string value of the provided option IDs to set the value of the attribute using setValueAsString(String).
(For multiple value attribute types the PM view components usually use the 'setListValueAsString' method signatures to set the selected option values.)

Returns:
The attribute options.
In case of no options an empty option set.

getValueLocalized

java.lang.String getValueLocalized()
Some attribute types, such as enums, may provide localized values.

It is sometimes useful to display in the UI rather 'Yes' and 'No' instead of 'TRUE' and 'FALSE'. For such situations implementations this method may provide the expected human readable string.
Another use case: An attribute that references a 'User' object might provide here the name of the referenced user.

Returns:
The localized string value for the current value.

getMaxLen

int getMaxLen()
Returns:
The maximum string representation length.

getMinLen

int getMinLen()
Returns:
The minimal string representation length.

isRequired

boolean isRequired()
Returns:
true if the attribute value needs to be set to a value that is not null.

resetPmValues

void resetPmValues()
Reset the value to null or the optional default value definition.

Specified by:
resetPmValues in interface PmDataInput

isPmValueChanged

boolean isPmValueChanged()
Indicates an attribute value change.

Will be cleared when

Specified by:
isPmValueChanged in interface PmDataInput
Returns:
true if the attribute value was changed in the live time of the PM (or since the previous value or changed state reset).

setPmValueChanged

void setPmValueChanged(boolean newChangedState)
Sets an attribute explicitly to a change or unchanged state.

Is usually used for the following scenarios:

An event with the type-flag PmEvent.VALUE_CHANGED_STATE_CHANGE will be fired if the call changed this state.

Parameters:
true - marks the attribute as changed.
false marks the attribute as unchanged.

getFormatString

java.lang.String getFormatString()
Returns a localized format string for attribute values provided as strings.
The localized format string is based on a resource key which may be defined as follows:
  1. You may specify it using the annotation PmAttrCfg.formatResKey().
  2. You may define it within the resource file, using a resource key with a '_format' postfix.
    Example: myPm.myNumber_format=#,##0.##
  3. For some types such as PmAttrDate and PmAttrDouble you may specify default formats.
    (Attribute classes may specify this by implementing getFormatDefaultResKey().)
    See: PmAttrDate.RESKEY_DEFAULT_FORMAT_PATTERN and PmAttrDouble.RESKEY_DEFAULT_FORMAT_PATTERN.
The resource key gets evaluated in the sequence specified above. The first resource key match wins.

Returns:
A localized format string or null if there is no format definition.