Stage 5: Implementing a filter to prevent learning child objects

In this section, you create a filter to prevent all of the UsedBooks control's children from being learned along with the control.

You implement this in the toolkit configuration file and in the JavaScript file.

To filter the children learned with the UsedBooks control:

  1. In the WebExtSample.xml file, within the Control element defined for the WebExtBook test object class, add the following Filter element:

    <Filter>
        <Learn learn_control="Yes" learn_children="CallFilterFunc" type="javascript" function="GetChildrenToLearn" />
    </Filter>
    

    This indicates that WebExtUsedBooks test objects should be learned when learning their parent Web pages, and that the JavaScript function GetChildrenToLearn should be called to determine which children to learn. The JavaScript function returns a SafeArray of the controls descendants that should be learned with the control.

    Note: You can modify the WebExtSample.xml file in the toolkit support set folder and then later deploy it to OpenText Functional Testing for testing, or you can modify <OpenText Functional Testing installdir>\dat\Extensibility\Web\Toolkits\WebExtSample\.xml directly.

  2. In the WebExtUsedBooks.js file, add the following functions:

    // Learn filtering
    // This function indicates which child objects of a 
    // UsedBooksTable should be learned with the object is learned. 
    function GetChildrenToLearn()
    {
        // Return all of the radio buttons in the UsedBooks table
        return toSafeArray(GetTableElem().getElementsByTagName("input") );
    }
    

    This ensures that only the radio buttons are learned, as planned in the outset of this lesson.

To complete this stage, perform the procedures in Deploying and testing the toolkit support set (for stage 5).