Class
caplin.presenter.node

NodeList

NodeList is a caplin.presenter.node.PresentationNode, that is itself a list of presentation nodes.

The NodeList class is useful when you have a list of nodes of the same type that all need to be rendered to screen. It supports the case where some or all of the nodes need to be rendered with different templates.

The contents of the NodeList class can be modified using the #updateList method, and this will cause the view to immediately update to reflect the contents of the new list. Node lists whose presentation nodes aren't all rendered with the same template can achieve this by having each of the nodes within the list implement the caplin.presenter.node.TemplateAware interface.

If fNodeClass is provided, then only instances of that class can be added to the node list; An caplin.core.Error will be thrown if this is violated.

Constructor Summary

Attributes Name and Description
caplin.presenter.node.NodeList(Array pPresentationNodes, Function fNodeClass)

Constructs a new instance of NodeList containing the given caplin.presenter.node.PresentationNode instances.

Method Summary

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

Convenience method that allows listeners to be added for objects that do not themselves implement caplin.presenter.node.NodeListListener.

caplin.presenter.node.NodeList addListener(caplin.presenter.node.NodeListListener oListener, boolean bNotifyImmediately)

Add a caplin.presenter.node.NodeListListener that will be notified each time the node list is updated.

Array getPresentationNodesArray()

Returns the list of caplin.presenter.node.PresentationNode instances as an array.

String getTemplateForNode(caplin.presenter.node.PresentationNode oPresentationNode)

Returns the name of the template used to render the given presentation node.

caplin.presenter.node.NodeList removeAllListeners()

Remove all previously added caplin.presenter.node.NodeListListener instances.

caplin.presenter.node.NodeList removeListener(caplin.presenter.node.NodeListListener oListener)

Remove a previously added caplin.presenter.node.NodeListListener.

void updateList(Array pPresentationNodes)

Updates the node list with a new array of caplin.presenter.node.PresentationNode instances.

Methods inherited from class caplin.presenter.node.PresentationNode:
getPath, nodes, properties, removeChildListeners

Constructor Detail

caplin.presenter.node.NodeList(Array pPresentationNodes, Function fNodeClass)

Constructs a new instance of NodeList containing the given caplin.presenter.node.PresentationNode instances.

Parameters
Array pPresentationNodes The initial array of caplin.presenter.node.PresentationNode instances
Function fNodeClass (optional) The class/interface that all nodes in this list should be an instance of

Method Detail

caplin.presenter.node.NodeListListener addChangeListener(Object oListener, String sMethod, boolean bNotifyImmediately)

Convenience method that allows listeners to be added for objects that do not themselves implement caplin.presenter.node.NodeListListener.

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

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.

caplin.presenter.node.NodeList addListener(caplin.presenter.node.NodeListListener oListener, boolean bNotifyImmediately)

Add a caplin.presenter.node.NodeListListener that will be notified each time the node list is updated.

Parameters
caplin.presenter.node.NodeListListener oListener The listener to be added.
boolean bNotifyImmediately Whether to invoke the listener immediately using the current node list.

Array getPresentationNodesArray()

Returns the list of caplin.presenter.node.PresentationNode instances as an array.

String getTemplateForNode(caplin.presenter.node.PresentationNode oPresentationNode)

Returns the name of the template used to render the given presentation node.

Parameters
caplin.presenter.node.PresentationNode oPresentationNode The presentation node being queried.

caplin.presenter.node.NodeList removeAllListeners()

Remove all previously added caplin.presenter.node.NodeListListener instances.

caplin.presenter.node.NodeList removeListener(caplin.presenter.node.NodeListListener oListener)

Remove a previously added caplin.presenter.node.NodeListListener.

Parameters
caplin.presenter.node.NodeListListener oListener The listener being removed.

void updateList(Array pPresentationNodes)

Updates the node list with a new array of caplin.presenter.node.PresentationNode instances.

Care must be taken to always invoke this method when the contents of the node list change. The array returned by #getPresentationNodesArray should be treated as being immutable.

Parameters
Array pPresentationNodes The new list of caplin.presenter.node.PresentationNode instances.