public class HTMLTree extends java.lang.Object implements HTMLTagElement, java.io.Serializable
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 | ||||||
| |||||||
Parent Element 2 | |||||||
Parent Element 3 |
HTMLTree objects generate the following events:
HTMLTreeElement
,
URLParser
,
Serialized FormConstructor and Description |
---|
HTMLTree()
Constructs a default HTMLTree object.
|
HTMLTree(javax.servlet.http.HttpServletRequest request)
Constructs an HTMLTree object with the specified HttpServletRequest.
|
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.
|
public HTMLTree()
public HTMLTree(javax.servlet.http.HttpServletRequest request)
request
- public void addElement(HTMLTreeElement element)
element
- The HTMLTreeElement.public void addElementListener(ElementListener listener)
listener
- The ElementListener.removeElementListener(com.ibm.as400.util.html.ElementListener)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removeElement(HTMLTreeElement element)
element
- The HTMLTreeElement.public void removeElementListener(ElementListener listener)
listener
- The ElementListener.addElementListener(com.ibm.as400.util.html.ElementListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The PropertyChangeListener.addPropertyChangeListener(java.beans.PropertyChangeListener)
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
public java.text.Collator getCollator()
public java.lang.String getFOTag()
getFOTag
in interface HTMLTagElement
public java.lang.String getTag()
getTag
in interface HTMLTagElement
public void setCollator(java.text.Collator collator)
collator
- The Collator.public void setHttpServletRequest(javax.servlet.http.HttpServletRequest request)
request
- The Http servlet request.public void sort(boolean sort)
sort
- true if the elements are sorted; false otherwise.
The default is true.public static java.util.Vector sort(java.text.Collator collator, java.util.Vector list)
collator
- The Collator, or null if the default Collator should be used.list
- The objects.