Sitetree can provide the implementation
for the generation of a dynamic site structure within a web application.
What this means is that navigation bars, link validation, personalized site structure, and security
can be generated using the Sitetree.
The developer only needs to add the presentation on the JSP page.
Consider the standard left navigation common to many web sites. It presents the following challenges:
-
If the number of pages in the site is large, maintaining the navigation is
complicated and error-prone.
-
Should the site require logins, a different navigation structure is required for each view that
a user could see.
-
You may want to change the navigation dynamically based on new resources that have
been posted to the site.
In short hand-coding navigation is almost impossible for large or complicated sites.
They need a subsystem that manages navigation.
Sitetree is such a system.
Sitetree is an in-memory representation of all the pages and links that a user can view.
A Sitetree has nodes and locations.
A node represents an item in the navigation bar that a user can click on.
A location is a URL that will receive a user request. Nodes can be grouped into components.
Components are used to construct complicated configurations on the fly.
A component is a collection of nodes with a single root node. When someone logs on,
you can determine that they require sections A, B, and D of your site, but not section C.
So you retrieve these sections (as Sitetree components) and add them to the user's Sitetree.
Their navigation bar is now automatically updated and allows them to navigate to the parts of the
site they have access to.
To use Sitetree as a security mechanism you need to validate each request as it comes in.
If it is on the user's Sitetree you let it in, otherwise you do not. The easiest way to do this
is to send all requests for your application to a single servlet and dispatch them from there.
This is standard practice and forms a robust and maintainable architecture.
The Sitetree package comes with such a servlet.
You can use this or use it as an example for writing your own.
Finally, while Sitetree components can be constructed by hard-coding them into your application
this is obviously not desirable. The Builder class allows you to parse and construct components
from a String stored in a configuration file, database, or other storage.
Builder is written using JavaCC and uses a well-defined grammar to represent the web site
navigation as a String. See the Usage section for more information.
|