Example

The following example, from the Erewhon Investments example schema supplied on the JADE release medium, shows the use of the beginNotification method when retrieving the next subset of items in reverse order from a collection to fill a list box.

zLoadSubsetReversed(whichEnd: Integer) updating, protected
// The whichEnd parameter is used to fill the list from the end of the list
// box if EndOfList, otherwise fill starting from the top of the list box.
vars
    linesInDisplay, idx : Integer;
    obj                 : Object;
begin
    linesInDisplay := self.lines;
    idx := self.listCount;
    if whichEnd = EndOfList then
        // Fill from the end of the list box
        while zMyIterator.back(obj) do
            idx := idx + 1;
            // Add the item text and object
            addItem(displayEntry(self, obj, idx));
            itemObject[idx] := obj;
            // If the entry was selected, then select it in the list
            if zSelectedObjects.includes(obj) then
                self.itemSelected[idx] := true;
            endif;
            zCurrentIteratorPosition := idx;
            if showUpdates then
                // We want to be told about changes to this object
                beginNotification(obj, Object_Update_Event,
                              Response_Continuous, NotifyInstanceUpdate);
            endif;
            if idx = linesInDisplay then
                break;                 // We've filled enough
            endif;
        endwhile;
    else
        // Fill from the start of the list box
        idx := 1;
        while zMyIterator.back(obj) do
            // Add the item text and object
            addItemAt(displayEntry(self, obj, idx), idx);
            itemObject[idx] := obj;
            // If the entry was selected, then select it in the list
            if zSelectedObjects.includes(obj) then
                itemSelected[idx] := true;
            endif;
            zCurrentIteratorPosition := idx;
            if showUpdates then
                // We want to be told about changes to this object
                beginNotification(obj, Object_Update_Event,
                                Response_Continuous, NotifyInstanceUpdate);
            endif;
            if self.listCount = linesInDisplay then
                break;                            // We've filled enough
            endif;
            idx := idx + 1;
        endwhile;
    endif;
end;