com.ibm.as400.util.html

Class HTMLTree

  • java.lang.Object
    • com.ibm.as400.util.html.HTMLTree
  • All Implemented Interfaces:
    HTMLTagElement, java.io.Serializable


    public class HTMLTree
    extends java.lang.Object
    implements HTMLTagElement, java.io.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 Summary

      Constructors 
      Constructor and Description
      HTMLTree()
      Constructs a default HTMLTree object.
      HTMLTree(javax.servlet.http.HttpServletRequest request)
      Constructs an HTMLTree object with the specified HttpServletRequest.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addElement(HTMLTreeElement element)
      Adds an HTMLTreeElement to the tree.
      void addElementListener(ElementListener listener)
      Adds an addElementListener.
      void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
      Adds a PropertyChangeListener.
      java.text.Collator getCollator()
      Returns the Collator.
      java.lang.String getFOTag()
      Returns a comment tag.
      javax.servlet.http.HttpServletRequest getHttpServletRequest()
      Returns the HttpServletRequest.
      java.lang.String getTag()
      Returns the HTMLTree tag.
      void removeElement(HTMLTreeElement element)
      Removes an HTMLTreeElement from the tree.
      void removeElementListener(ElementListener listener)
      Removes this ElementListener from the internal list.
      void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
      Removes the PropertyChangeListener from the internal list.
      void setCollator(java.text.Collator collator)
      Sets the collator.
      void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
      Sets the Http servlet request.
      void sort(boolean sort)
      Sorts the elements within the HTMLTree.
      static java.util.Vector sort(java.text.Collator collator, java.util.Vector list)
      Sorts a vector of objects.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
        Parameters:
        request -
    • 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)
      • addPropertyChangeListener

        public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
        Adds a PropertyChangeListener. The specified PropertyChangeListener's propertyChange method is called each time the value of any bound property is changed.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        removePropertyChangeListener(java.beans.PropertyChangeListener)
      • removeElement

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

        public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
        Removes the PropertyChangeListener from the internal list. If the PropertyChangeListener is not on the list, nothing is done.
        Parameters:
        listener - The PropertyChangeListener.
        See Also:
        addPropertyChangeListener(java.beans.PropertyChangeListener)
      • getHttpServletRequest

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

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

        public java.lang.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.
      • getTag

        public java.lang.String getTag()
        Returns the HTMLTree tag.
        Specified by:
        getTag in interface HTMLTagElement
        Returns:
        The tag.
      • setCollator

        public void setCollator(java.text.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 java.util.Vector sort(java.text.Collator collator,
                            java.util.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.