## DFrameCollector class

The DFrameCollector class has no public constructor. Only one object, the DFrameCollector object, is created from this class. This is automatically done when the dFrameAPI loads.

The DFrameCollector object manages closed DFrames in order to reuse them.

### Example

function openDFrame(urlForDFrame) {

//define a key for this kind of dFrame

var key = 'keyForDFrameOfThisType'

//look for a dFrame with this key in the dFrameCollector

dFrame = DFrameCollector.find(key)

//if not found: create a new dFrame

if ( !dFrame ) dFrame = instantiateDFrame(key)

dFrame.setURL(urlForDFrame)

}

function instantiateDFrame(key) {

var dFrame = new DFrame(parameters)

dFrame.addButton('Close', 'this.closeFrame()')

//register the dFrame in the dFrameCollector for reuse

DFrameCollector.register(dFrame, key)

return dFrame

}

Demo

file: setTarget.html

Run the example
See the source code

### Methods

### register

#### Example

var dFrame = new DFrame(parameters);

DFrameCollector.register(dFrame, 'keyForThisDFrame')

#### Syntax

DFrame.register(dFrame, key)

#### Parameters

dFrame:A DFrame object

key

String: The key that will be used to find a DFrame with the find method.

#### Return value

No return value

### find

#### Example

var dFrame = DFrameCollector.find(dFrame, 'keyForThisDFrame')

if (!dFrame) var dFrame = new DFrame(parameters)

dFrame.setURL(url)

#### Syntax

DFrame.find(key)

#### Parameters

key

String: The key that was used to register a DFrame in the DFrameCollector.

#### Return value

DFrame object

### Usage

When a DFrame is closed it is not destroyed but only hidden. Closed DFrames can be reused if they are registered in the DFrameCollector.

In order to store many kinds of DFrames in the DFrameCollector and retrieve only DFrames of one category a key is added to DFrames when they are registered. The find method will look for only DFrames having the same key.

When a DFrame is found by the find method it is automatically removed from the DFrameCollector and will be stored again in it when the closeFrame method will be used.