| Package | system.models.arrays |
| Class | public class PageableArrayModel |
| Inheritance | PageableArrayModel ChangeModel KernelModel Object |
| Implements | OrderedIterator, Runnable |
Array model with a 'page by page' iterator.
| Property | Defined By | ||
|---|---|---|---|
![]() | beforeChanged : Signaler [read-only]
Emits a message before the current object in the model is changed. | ChangeModel | |
![]() | changed : Signaler [read-only]
Emits a message when the current object in the model is changed. | ChangeModel | |
![]() | cleared : Signaler [read-only]
Emits a message when the current object in the model is cleared. | ChangeModel | |
| count : uint
Determinates the number of elements in a page of this model. | PageableArrayModel | ||
![]() | current : *
Determinates the selected value in this model. | ChangeModel | |
| currentPage : uint
Indicates the current page selected in the model. | PageableArrayModel | ||
| initialized : Signaler [read-only]
Returns the event name use in the notifyInit method. | PageableArrayModel | ||
| length : uint [read-only]
Indicates the number of elements in the model. | PageableArrayModel | ||
| pageCount : Number [read-only]
Indicates the numbers of page with the current model. | PageableArrayModel | ||
![]() | security : Boolean = true
This property defined if the current property can accept the same object in argument as the current one. | ChangeModel | |
| updated : Signaler [read-only]
Returns the event name use in the notifyUpdate method. | PageableArrayModel | ||
| Method | Defined By | ||
|---|---|---|---|
PageableArrayModel(count:uint = 1, factory:Array = null)
Creates a new PageableArrayModel instance. | PageableArrayModel | ||
clear():void [override]
Clear the model. | PageableArrayModel | ||
firstPage():void
Seek the iterator in the first page of this object. | PageableArrayModel | ||
getByKey(key:*, primaryKey:String = id):Object
Returns the object defined by the key passed in argument and register in the model. | PageableArrayModel | ||
hasNext():Boolean
Returns true if the list has a next page. | PageableArrayModel | ||
hasPrevious():Boolean
Returns true if the list has a previous page. | PageableArrayModel | ||
init(datas:Array, autoClear:Boolean = true, autoRefresh:Boolean = true):void
Fill and initialize the model with an Array of ValueObject. | PageableArrayModel | ||
![]() | isLocked():Boolean
Returns true if the object is locked. | KernelModel | |
key():*
Returns the current key of the internal pointer of the iterator (optional operation). | PageableArrayModel | ||
lastPage():void
Seek the iterator in the last page of this object. | PageableArrayModel | ||
![]() | lock():void
Locks the object. | KernelModel | |
next():*
Show the next page of the model. | PageableArrayModel | ||
![]() | notifyBeforeChange(value:*):void
Notify a signal before the specified value is changed. | ChangeModel | |
![]() | notifyChange(value:*):void
Notify a signal when the model is changed. | ChangeModel | |
![]() | notifyClear():void
Notify a signal when the model is cleared. | ChangeModel | |
notifyInit():void
Emit a message when the model is initialized. | PageableArrayModel | ||
notifyUpdate(value:*):*
Emit a message when the model is updated. | PageableArrayModel | ||
pageOf(value:Object):uint
Finds and indicates the page number of the specified value object register in the model. | PageableArrayModel | ||
previous():*
Show in the previous page in the list or previous screen. | PageableArrayModel | ||
refresh():void
Refresh the iterator of the model and run it. | PageableArrayModel | ||
remove():*
Removes from the underlying model the last element returned by the iterator (optional operation). | PageableArrayModel | ||
reset():void
Resets the key pointer of the iterator. | PageableArrayModel | ||
run(... arguments):void
Run the model when is initialize. | PageableArrayModel | ||
seek(position:*):void
Seek the position of the pointer in the model but don't notify an update signal. | PageableArrayModel | ||
![]() | supports(value:*):Boolean
Returns true if the Validator object validate the value. | KernelModel | |
toArray():Array
Returns a new Array representation of all elements in this model. | PageableArrayModel | ||
![]() | unlock():void
Unlocks the display. | KernelModel | |
![]() | validate(value:*):void
Evaluates the specified value and throw a TypeError object if the value is not valid. | KernelModel | |
| count | property |
count:uintDeterminates the number of elements in a page of this model.
public function get count():uint public function set count(value:uint):void| currentPage | property |
currentPage:uintIndicates the current page selected in the model.
public function get currentPage():uint public function set currentPage(value:uint):void| initialized | property |
initialized:Signaler [read-only]
Returns the event name use in the notifyInit method.
public function get initialized():Signaler| length | property |
length:uint [read-only] Indicates the number of elements in the model.
public function get length():uint| pageCount | property |
pageCount:Number [read-only] Indicates the numbers of page with the current model.
public function get pageCount():Number| updated | property |
updated:Signaler [read-only]
Returns the event name use in the notifyUpdate method.
public function get updated():Signaler| PageableArrayModel | () | Constructor |
public function PageableArrayModel(count:uint = 1, factory:Array = null)Creates a new PageableArrayModel instance.
Parameterscount:uint (default = 1) — Indicates the default number of elements by page in the model (default 1).
| |
factory:Array (default = null) — the optional internal Array reference to build the model, by default an empty Array is created.
|
| clear | () | method |
override public function clear():voidClear the model.
| firstPage | () | method |
public function firstPage():voidSeek the iterator in the first page of this object.
| getByKey | () | method |
public function getByKey(key:*, primaryKey:String = id):ObjectReturns the object defined by the key passed in argument and register in the model.
Parameters
key:* | |
primaryKey:String (default = id) |
Object — the object defined by the key passed in argument and register in the model.
|
| hasNext | () | method |
public function hasNext():Boolean
Returns true if the list has a next page.
Boolean — true if the list has a next page.
|
| hasPrevious | () | method |
public function hasPrevious():Boolean
Returns true if the list has a previous page.
Boolean — true if the list has a previous page.
|
| init | () | method |
public function init(datas:Array, autoClear:Boolean = true, autoRefresh:Boolean = true):voidFill and initialize the model with an Array of ValueObject.
Parameters
datas:Array — The array of all value objects to insert in the model.
| |
autoClear:Boolean (default = true) — (optional) If this argument is true the clear method is invoked when the initialization begin.
| |
autoRefresh:Boolean (default = true) — (optional) If this argument is true the model is running when this initialization is finished.
|
| key | () | method |
public function key():*Returns the current key of the internal pointer of the iterator (optional operation).
Returns* — the current key of the internal pointer of the iterator (optional operation).
|
| lastPage | () | method |
public function lastPage():voidSeek the iterator in the last page of this object.
| next | () | method |
public function next():*Show the next page of the model.
Returns* |
| notifyInit | () | method |
public function notifyInit():voidEmit a message when the model is initialized.
| notifyUpdate | () | method |
public function notifyUpdate(value:*):*Emit a message when the model is updated.
Parameters
value:* |
* |
| pageOf | () | method |
public function pageOf(value:Object):uintFinds and indicates the page number of the specified value object register in the model. If the passed-in value object is not found 0 is returned.
Parameters
value:Object |
uint |
| previous | () | method |
public function previous():*Show in the previous page in the list or previous screen.
Returns* |
| refresh | () | method |
public function refresh():voidRefresh the iterator of the model and run it.
| remove | () | method |
public function remove():*Removes from the underlying model the last element returned by the iterator (optional operation).
Returns* |
IllegalOperationError — The PageableArrayModel remove method is unsupported.
|
| reset | () | method |
public function reset():voidResets the key pointer of the iterator.
| run | () | method |
public function run(... arguments):voidRun the model when is initialize. This method don't work if the model is locked.
Parameters
... arguments |
See also
| seek | () | method |
public function seek(position:*):voidSeek the position of the pointer in the model but don't notify an update signal.
Parameters
position:* |
| toArray | () | method |
public function toArray():ArrayReturns a new Array representation of all elements in this model.
ReturnsArray — a new Array representation of all elements in this model.
|
package examples
{
import core.dump;
import system.models.arrays.PageableArrayModel;
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class PageableArrayModelExample extends Sprite
{
public function PageableArrayModelExample()
{
stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
model = new PageableArrayModel( 2 ) ;
// model.count = 3 ;
model.initialized.connect( init ) ;
model.updated.connect( update ) ;
var datas:Array = [] ;
for ( var i:uint = 0 ; i < 20 ; i++ )
{
datas.push( { id:i } ) ;
}
model.init( datas , false , false ) ;
model.currentPage = 2 ;
}
protected var model:PageableArrayModel ;
protected function init( model:PageableArrayModel ):void
{
trace( model + " init" ) ;
}
protected function update( value:* , model:PageableArrayModel ):void
{
trace( model + " update " + model.currentPage + "/" + model.pageCount + " value:" + dump(value) ) ;
}
protected function keyDown( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.LEFT :
{
if ( model.hasPrevious() )
{
model.previous() ;
}
else
{
model.lastPage() ;
}
break ;
}
case Keyboard.RIGHT :
{
if ( model.hasNext() )
{
model.next() ;
}
else
{
model.firstPage() ;
}
break ;
}
case Keyboard.SPACE :
{
model.lock() ;
model.count = 4 ; // change the count value but not update the model.
model.unlock() ;
}
}
}
}
}