| Java menu knowledge base Hybrid java-javascript menus
Introduction
It is possible to combine our java menus with javascript (or other client-side scripts)
to dynamically populate the java menu at runtime. (The difference between java
and javascript is described here).
It is also possible to use client-side scripts to manipulate the content of the
java menu after it has been populated for each session. This second topic is not
the subject of this article - it is discussed under exposed methods.
Likewise it is possible for you to get your java menu to trigger javascripts - this is
also a different topic addressed under java-to-javascript menus
To recap, this article covers populating a java menu using javascript or any other client-side
scripting language.
Conditional parameters
Most of our commercial menus can read their content (text and hyperlinks) from both
external files and parameters. External files are files other than the HTML file with
the menu. Parameters are special HTML tags contained within the same HTML file as the menu.
A parameter which creates a menu item in a menu might look like this:
<param name=entry0 value="TEXT:my text|1|2|LINK:myPage.htm,myFrame|comment">
The format for such parameter indices is described further here.
As a parameter is a tag just like any other piece of HTML, it can be manipulated dynamically using
client-side scripts such as javascript. For example, you could write a javascript condition
which forks between two different document.write() statements, which write different
menu items.
<script>
if (username=="bob") document.write("<param name=entry0 value='TEXT:Bob's menu|1|2|LINK:bob.htm| '>");
else document.write("<param name=entry0 value='TEXT:General menu|1|2|LINK:general.htm| '>");
</script>
More complex scripting
Once you've understood the principle that parameters can be dynamically generated, you can quickly
stretch to your full abilities as a javascript programmer - for example, by connecting up arrays
to your parameters.
However before you get too carried away by this kind of thing, remember that java is much more
efficient than javascript and makes better use of client-side resources. If you end up with a javascript
that effectively manages a large client-side javascript database, this is highly inefficient and may
lead to poor performance. For large scale applications, your dynamic scripting should be done on
the server and read directly from the server by the applet - this is a much
more elegant way of creating dynamic content for java menus.
Javascript menus with javascript only
For the same reason as stated above (the comparatively inefficient use of clients-side resources),
pure javascript menus are not recommended. A well-programmed java menu will always be faster and capable of handling
much greater volumes. Javascript is best used for adding small custom utilities around a java
menu.
|
|