The DhElement Class
Elements are objects derived from DhElement, which is the superclass of all user interface elements in the wfc.html package. There is a certain consistency you can count on when using any object derived from DhElement:
-
Every element has an empty constructor. This means you can instantiate any element with simply a new and then set properties, hook event handlers, and call methods in a very consistent way.
-
Elements are stateless. In other words, setting properties or calling methods always works and is not conditional on some external state or circumstance.
-
Every container has an add() method that takes the type-safe element that is appropriate for it.
-
In the browser environment, an element does not become visible to the end-user until you add it (or the topmost container element in its parentage) to the document. However, this is merely an artifact and not part of the programming model. You don't have to change the way you program to elements as they work the same way whether they are live or not.
If an element is already on the page when the documentLoad() method is called, then you can call the document's findElement() method and start programming to that element. The searching routine used by findElement assumes that the element you are looking to find has an ID attribute set to a particular name. You can also enumerate all the elements in the document until you find the one you are interested in.