Class
caplin.presenter.property

Property

Instances of Property are used to store all the values held within a presentation model.

Each value within a presentation model is stored within a single Property instance, and updates to properties are displayed immediately within the view. The displayed value may be formatted prior to display if any formatters have been added using the #addFormatter method.

A few varieties of property are available:

caplin.presenter.property.Property:
Used for properties that are not writable by the end-developer, and whose value is updated automatically on behalf of the end-developer.
caplin.presenter.property.WritableProperty:
Used for properties that are completely accessible to the end-developer, but which are not editable by the end-user.
caplin.presenter.property.EditableProperty:
Used for properties that need to be editable by the end-user, and writable by the end-developer.

Constructor Summary

Attributes Name and Description
caplin.presenter.property.Property(Object vValue)

Constructs a new Property instance — you will probably never want to construct a Property yourself since they are not writable.

Method Summary

Attributes Name and Description
caplin.presenter.property.PropertyListener addChangeListener(Object oListener, String sMethod, boolean bNotifyImmediately)

Convenience method that allows a change listener to be added to added for objects that do not themselves implement caplin.presenter.property.PropertyListener.

caplin.presenter.property.Property addFormatter(caplin.core.Formatter oFormatter, Object mConfig)

Add a caplin.core.Formatter that will be applied to the property before it's rendered to screen.

caplin.presenter.property.Property addListener(caplin.presenter.property.PropertyListener oListener, boolean bNotifyImmediately)

Add a caplin.presenter.property.PropertyListener that will be notified each time the property is updated.

caplin.presenter.property.PropertyListener addUpdateListener(Object oListener, String sMethod, boolean bNotifyImmediately)

Convenience method that allows an update listener to be added to added for objects that do not themselves implement caplin.presenter.property.PropertyListener.

Object getFormattedValue()

Returns the formatted value for this property if any formatters have been attached, otherwise returns the raw property value.

String getPath()

Returns the path that would be required to bind this property from the view.

Object getRenderedValue()

Returns the rendered value if this value is being rendered using the Caplin renderer library, otherwise returns the raw property value.

Object getValue()

Returns the unformatted value for this property.

caplin.presenter.property.Property removeAllListeners()

Remove all previously added caplin.presenter.property.PropertyListener instances.

caplin.presenter.property.Property removeListener(caplin.presenter.property.PropertyListener oListener)

Remove a previously added caplin.presenter.property.PropertyListener.

Constructor Detail

caplin.presenter.property.Property(Object vValue)

Constructs a new Property instance — you will probably never want to construct a Property yourself since they are not writable.

Parameters
Object vValue (optional) The default value for this property.

Method Detail

caplin.presenter.property.PropertyListener addChangeListener(Object oListener, String sMethod, boolean bNotifyImmediately)

Convenience method that allows a change listener to be added to added for objects that do not themselves implement caplin.presenter.property.PropertyListener.

Listeners added using addChangeListener() will only be notified when caplin.presenter.property.PropertyListener#onPropertyChanged fires, and will not be notified if any of the other caplin.presenter.property.PropertyListener call-backs fire. The advantage to using this method is that objects can choose to listen to call-back events on multiple properties.

Parameters
Object oListener The listener to be added.
String sMethod The name of the method on the listener that will be invoked each time the property changes.
boolean bNotifyImmediately Optional (optional) Whether to invoke the listener immediately for the current value.

caplin.presenter.property.Property addFormatter(caplin.core.Formatter oFormatter, Object mConfig)

Add a caplin.core.Formatter that will be applied to the property before it's rendered to screen.

Any number of formatters can be added to a property, and will be applied in the same order in which the formatters were added.

Parameters
caplin.core.Formatter oFormatter The formatter being added.
Object mConfig (optional) Any additional configuration for the formatter.

caplin.presenter.property.Property addListener(caplin.presenter.property.PropertyListener oListener, boolean bNotifyImmediately)

Add a caplin.presenter.property.PropertyListener that will be notified each time the property is updated.

Parameters
caplin.presenter.property.PropertyListener oListener The listener to be added.
boolean bNotifyImmediately Whether to invoke the listener immediately using the current value.

caplin.presenter.property.PropertyListener addUpdateListener(Object oListener, String sMethod, boolean bNotifyImmediately)

Convenience method that allows an update listener to be added to added for objects that do not themselves implement caplin.presenter.property.PropertyListener.

Listeners added using addUpdateListener() will only be notified when caplin.presenter.property.PropertyListener#onPropertyUpdated fires, and will not be notified if any of the other caplin.presenter.property.PropertyListener call-backs fire. The advantage to using this method is that objects can choose to listen to call-back events on multiple properties.

Parameters
Object oListener The listener to be added.
String sMethod The name of the method on the listener that will be invoked each time the property changes.
boolean bNotifyImmediately (optional) Whether to invoke the listener immediately for the current value.

Object getFormattedValue()

Returns the formatted value for this property if any formatters have been attached, otherwise returns the raw property value.

String getPath()

Returns the path that would be required to bind this property from the view.

This method is used internally, but might also be useful in allowing the dynamic construction of views for arbitrary presentation models.

Object getRenderedValue()

Returns the rendered value if this value is being rendered using the Caplin renderer library, otherwise returns the raw property value.

Object getValue()

Returns the unformatted value for this property.

caplin.presenter.property.Property removeAllListeners()

Remove all previously added caplin.presenter.property.PropertyListener instances.

caplin.presenter.property.Property removeListener(caplin.presenter.property.PropertyListener oListener)

Remove a previously added caplin.presenter.property.PropertyListener.

Parameters
caplin.presenter.property.PropertyListener oListener The listener being removed.