com.ibm.as400.util.html

Class HTMLTree

  • All Implemented Interfaces:
    HTMLTagElement, Serializable


    public class HTMLTree
    extends Object
    implements HTMLTagElement, Serializable
    The HTMLTree class represents an HTML hierarchical tree of HTML elements.

    This example creates an HTMLTree object with five elements. The first three elements will be added directly to the HTMLTree and the remaining two elements will extend off one of the first three elements.

      // Create a URLParser object.
      URLParser urlParser = new URLParser(myHttpServletRequest.getRequestURI());
      

    // Create parent HTMLTreeElements. HTMLTreeElement parentElement = new HTMLTreeElement(); parentElement.setTextUrl(new HTMLHyperlink("http://myWebPage", "My Web Page"));

    HTMLTreeElement parentElement2 = new HTMLTreeElement(); parentElement2.setText(new HTMLText("Parent Element 2"));

    HTMLTreeElement parentElement3 = new HTMLTreeElement(); parentElement3.setText(new HTMLText("Parent Element 3"));

    // Create children HTMLTreeElements. HTMLTreeElement childElement1 = new HTMLTreeElement(); childElement1.setTextUrl(new HTMLHyperlink("http://anotherWebPage", "Another Web Page")); parentElement.addElement(childElement1);

    // Create a child of the first Child Element. HTMLTreeElement subChildElement1 = new HTMLTreeElement(); subChildElement1.setText(new HTMLHyperlink("http://myHomePage", "Home"));

    // Add the sub-child to the parent child element. childElement1.addElement(subChildElement1);

    // Set the URL link for the Expand/Collapsed Icon. ServletHyperlink iconUrl = new ServletHyperlink(urlParser.getURI()); iconUrl.setHttpServletResponse(resp); parentElement.setIconUrl(iconUrl); parentElement2.setIconUrl(iconUrl); parentElement3.setIconUrl(iconUrl);

    // Add the parent elements to the tree. tree.addElement(parentElement); tree.addElement(parentElement2); tree.addElement(parentElement3);

    When the HTMLTree is first viewed in a browser, none of the elements in the tree will be expanded, so the tree will look like this:

    + My Web Page
    Parent Element 2
    Parent Element 3

    When the elements in the HTMLTree are expanded by traversing the hierarchy, the tree will look like:

    - My Web Page
     
    - Another Web Page
     
    Home
    Parent Element 2
    Parent Element 3

    HTMLTree objects generate the following events:

    • ElementEvent - The events fired are:
      • elementAdded
      • elementRemoved
    • PropertyChangeEvent
    See Also:
    HTMLTreeElement, URLParser, Serialized Form
    • Constructor Detail

      • HTMLTree

        public HTMLTree()
        Constructs a default HTMLTree object.
      • HTMLTree

        public HTMLTree(javax.servlet.http.HttpServletRequest request)
        Constructs an HTMLTree object with the specified HttpServletRequest. The request is the mechanism used to provide continuity while expanding and collapsing the tree.
    • Method Detail

      • addElement

        public void addElement(HTMLTreeElement element)
        Adds an HTMLTreeElement to the tree.
        Parameters:
        element - The HTMLTreeElement.
      • addElementListener

        public void addElementListener(ElementListener listener)
        Adds an addElementListener. The specified addElementListeners elementAdded method will be called each time a RadioFormInput is added to the group. The addElementListener object is added to a list of addElementListeners managed by this RadioFormInputGroup. It can be removed with removeElementListener.
        Parameters:
        listener - The ElementListener.
        See Also:
        removeElementListener(com.ibm.as400.util.html.ElementListener)
      • removeElement

        public void removeElement(HTMLTreeElement element)
        Removes an HTMLTreeElement from the tree.
        Parameters:
        element - The HTMLTreeElement.
      • getHttpServletRequest

        public javax.servlet.http.HttpServletRequest getHttpServletRequest()
        Returns the HttpServletRequest.
        Returns:
        The request.
      • getCollator

        public Collator getCollator()
        Returns the Collator.
        Returns:
        The collator.
      • getFOTag

        public String getFOTag()
        Returns a comment tag. This method should not be called. There is no XSL-FO support for this class.
        Specified by:
        getFOTag in interface HTMLTagElement
        Returns:
        The comment tag.
      • setCollator

        public void setCollator(Collator collator)
        Sets the collator. The collator allows the tree to perform locale-sensitive String comparisons when sorting the tree elements.
        Parameters:
        collator - The Collator.
      • setHttpServletRequest

        public void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
        Sets the Http servlet request. The request is the mechanism used to provide continuity while expanding and collapsing the tree.
        Parameters:
        request - The Http servlet request.
      • sort

        public void sort(boolean sort)
        Sorts the elements within the HTMLTree.
        Parameters:
        sort - true if the elements are sorted; false otherwise. The default is true.
      • sort

        public static Vector sort(Collator collator,
                  Vector list)
        Sorts a vector of objects.
        Parameters:
        collator - The Collator, or null if the default Collator should be used.
        list - The objects.
        Returns:
        The sorted Vector.