Tags:
create new tag
, view all tags
-- PedroRio - 30 Dec 2010

BridgeHandler - Handler for a collection attribute

The bridgeHandler class is a handler for collection attributes. It allows to iterate through the collection, add new elements to the collection, remove elements and re-order the elements inside the collection ( elements in XEO's collections are ordered). Bellow is the list of methods that allow interaction with a collection attribute

Definition

Methods in these category allow to query the Object Model definition for the given collection attribute

Method name Description Parameters Return type Notes
getName Retrieves the name of the collection attribute (as declared in the Object Model) - String  
getDefAttribute Retrieves the handler for the Object Model definition of the collection attribute - boDefAttribute  

_

Iteration

Iteration methods allow to iterate through elements of the collection as well as interacting with the content of the collection. As explained before, the collection attribute contains an ordered list of elements and can be iterated from the first to the last element (collection attributes are not paged, like boObjectList instances).

Method name DescriptionSorted descending Parameters Return type Notes
getParent Retrieves the boObject instance which own the collection attribute - boObject  
getObject Retrieves the boObject instance in the current position of the iterator - boObject Throws runtime exception1
getEboContext Retrieves an EboContext instance - EboContext  
beforeFirst Resets the iterator to the beginning of the collection (before the first position of the collection, so that a call to next() will return the first element) - void Issuing a beforeFirst() command on the iterator allows to issue a next() command afterwards and retrieve the first element
truncate Removes all elements from the collection (final size is zero) - void  
last Positions the iterator in the last position of the collection - void  
first Positions the iterator in the first position of the collection - void  
moveTo Moves the iterator the desired position (passed as parameter) int line boolean Returns whether or not the iterator was moved to the desired position
moveRowTo Moves the current element to a specified position int position void This method will trigger the onBeforeChangeOrder and onAfterChangeOrder events in any collection attribute that defines them.
addNewObject Creates a new boObject instance adds it to the bridge and returns a reference to it. String objectName boObject  
isEmpty Checks whether the collection is empty or not - boolean  
next Advances the iterator to the next position of the collection - boolean If no more elements are available in the iterator this method returns false

_

Behavior

Collection attributes, like non-collection attributes, have associated behavior which can be invoked/queried through the API. The following methods are available:

Method name Description Parameters Return type Notes
required Whether the attribute is required or not (executes user code if it's defined) - boolean  
disableWhen Whether the attribute is disabled or not (executes user code if it's defined) - boolean  
         

valid()- Não funciona

hiddenWhen() - Não funciona

defaultValue() - Não funciona

formula() - Não funciona

_

Sample Code : Iterating through a collection attribute and updating the objects

_

        boObject obj = ... //loadObject; 
        //Retrieve the bridge
        bridgeHandler collectionHandler = obj.getBridge("collectionAttributeName");
        boBridgeIterator it = collectionHandler.iterator();
        //Iterate through all elements
        while (it.next()){
            try {
                //Retrieve the current object
                boObject current = it.currentRow().getObject();
                //Change a value and update
                current.getAttribute("foo").setValueString("bar");
                current.update();
            } catch (boRuntimeException e) {
                //Deal with the exception
            }
        }

_

Topic revision: r8 - 2012-01-16 - PedroRio
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar