Conceptual question...

T

Todd Prickett

Hi,
I'm a newbie with two questions, one conceptual and one technical,
about building a menubar for a struts/taglib/tiles based website.

The conceptual question is... I want to include a menubar in each of
my pages. To me, this seems like it should be a tile. However,
beyond that, I'm not sure what the best way to do this would be. My
initial thought was to create a class that reads an XML config file,
then build the HTML in my class. That HTML would then be rendered in
the resultant JSP. How would you experts handle this? I realize
there is a scripting component to taglibs, but don't think that adding
pages of taglib scripts to my JSP is the answer (is it?).

The technical question is... I stumbled across the HTML specific XML
libraries (i.e. org.w3c.dom.html). Is this a favored way of
constructing HTML within code or is there a better way? A
google/google-groups search returns VERY few results for classes
within that lib, which makes me suspect its not in vogue to use it.
If it is in vogue, can anyone provide a link to how to use them?
Javadocs on Sun's site show their syntax, but not really how to use
them.

Thanks, I look forward to hearing your opinions!
 
S

Sudsy

Todd Prickett wrote:
The conceptual question is... I want to include a menubar in each of
my pages. To me, this seems like it should be a tile. However,
beyond that, I'm not sure what the best way to do this would be. My
initial thought was to create a class that reads an XML config file,
then build the HTML in my class. That HTML would then be rendered in
the resultant JSP. How would you experts handle this? I realize
there is a scripting component to taglibs, but don't think that adding
pages of taglib scripts to my JSP is the answer (is it?).
<snip>

The answer is ... it depends. <GROAN/> Seriously, on one of my sites I
use Javascript code to handle the menus while the application I'm
building now uses struts tags to iterate over menu selections stored
in page scope. I'd definitely avoid the use of scriptlets, however.
 
M

Michael Scovetta

Todd,
Here's an answer for your 1st question. The way I do it is that I
don't generate menu content dynamically. None of my applications have
dynamic menus (the most is that some people see different menus, but
they're all static). I use XMenu
(webfx.eae.net/dhtml/xmenu/xmenu.html) and so I have a file, menu.js
which contains some simple commands to create the menus. If the site
has the same menu for everyone, then just include the .js via HTML:
<script type="text/javascript" src="menu.js"></script>

If you want to make it dynamic, do:
<jsp:include page="menu.js" />
so that the page is rendered with <%...%> markup.

You could easily do an xml-based menu system, but it'll take work to
transform the xml into the JavaScript to throw to XMenu. I would not
recommend writing your own menu code, it's tedious and it's tough to
get exactly write (for all browsers, etc).

Since menus are a client-side thing, I don't feel that taglibs are
appropriate-- sure you can use them for it, but you don't need
something that powerful.

Michael Scovetta
 
S

Sudsy

Michael said:
Since menus are a client-side thing, I don't feel that taglibs are
appropriate-- sure you can use them for it, but you don't need
something that powerful.

Depends on the application. I need complex navigation for my on-line
store and so everything's based on dynamic page content. I also use
tiles. I don't believe it to be overkill for this scenario.
I guess it comes down to the complexity of the menu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top