| Java menu knowledge base Dynamic Indices
Databases & dynamic indices
Using dynamically generated external index files is a powerful and elegant solution.
Most of our java menus have a parameter like this:
<PARAM name="menufile" value="index.txt">
In some applets the parameter name may vary - see documentation.
This parameter normally points to a static TXT file on the server
with a standard format explained here. However
there is no reason why this should be a static TXT file. You can
enter any URL of your choice as the value of the menufile
parameter. For example:
<PARAM name="menufile" value="index_creating_script.pl">
<PARAM name="menufile" value="search.pl?query=concept">
<PARAM name="menufile" value="index.htm">
<PARAM name="menufile" value="index.shtml">
<PARAM name="menufile" value="index.php?user=bob">
<PARAM name="menufile" value="index.jsp">
<PARAM name="menufile" value="imint_index.asp">
Please observe the following:
- The index source (i.e. your script) must be local to the applet - i.e. it must be in the applet's
own directory or a sub-directory of this.
- The index source must have a file extension (.pl, .php, .jsp, .asp, etc) which
is allowed by the server and must be readable.
- The index source must return (via STDOUT) an ASCII stream in the same format
as the static TXT files. Usually this is done with a simple sequence of output
statements (e.g. PHP's echo statement or perl's print statement).
It is a simple as outputting an HTML page - just the format is different.
- Ensure that no extra headers are written to the ascii stream as this might currupt
the format. For example, a Cold Fusion server might be configured to automatically add headers to
anything it generates - you would have to disable this for the script in question.
- Query strings can be used (and are useful!).
- You are strongly advised to check the format by reading it into a browser window
before reading it into an applet. For example, if you point the applet to
myMenu.php, point the browser at myMenu.php first to check the format and (!)
view the page source - because it's the page source which shows the real format - the browser
view itself might hide rogue tags and headers, or not show line breaks correctly. If the browser can't
read your script, the applet won't be able to either.
Note that you may also wish to combine dynamic parameter generation
and dynamic index generation. For example, a parameter such as:
<PARAM name="menufile" value="search.pl?query=concept">
...could be dynamically manipulated by a client-side script using, for example,
conditional document.write() statements.
|
|