Basic Layout Menu
Hello,
I need to have a simple layout like this: A menu at left and a content content area at right. The Menu consists of a dynamic list of links (different number of links for every user).
I have just learned to use Tiles, and I know how to authenticate users and get their links from a database. The question is:
How do I update (pass parameters + update to) the content area on the right when the user presses a link in the menu?
Any hint or link would be nice.
Thank you for your time.
[529 byte] By [
nezarda] at [2007-11-26 21:13:59]

# 1
You chould do that with (X)HTML DIV tags and CSS or you could use HTML frames.
DIV tags and CSS is the better option.
With CSS styling you can hide and show DIV tags.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Another option is to include JSP pages conditionally either with the jsp:include tag or JSTL's c:import tag or the equivalent of those in struts.
# 2
Appy77,
Thank you for your answer.
If I choose the <c:import> or <jsp:include>:
Let's say I have designed an HTML table, with just two columns (left-right -: basically two cells), the left being the menu, where I include the menu.jsp page. In the menu.jsp file I have few links. How do I check which links the user follows in order to present them in the right column every time?
# 3
You're welcome.
One simple way would be to use a URL with a query string parameter for each menu.
For example if your menu items are like this:
<a href="/mypage.jsp?showSection=a">Menu Item 1</a>
<a href="/mypage.jsp?showSection=b">Menu Item 2</a>
<a href="/mypage.jsp?showSection=c">Menu Item 3</a>
Then when the user clicks on say Menu Item 2 , the request parameter showSection is sent to the server, (myPage.jsp) , then in myPage.jsp
you could use
<% request.getParameter("showSection"); %>
, then put a series of If then else statements that decide which section to show, and inside each if / else , have your jsp:include or c:import
If you're using JSTL 1.1 , instead of the scriptlet <% request.getParameter("showSection"); %>
you could write the request.getParameter more neatly as
${param.showSection}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't know Ajax, but with Ajax you could make the menu selection appear seamless to the user - they wouldn't see the page refresh every time a menu item was clicked.
# 4
Thanks again abby77,
So the only way to update (refresh) only one part of the page (like we do with frames) is with Ajax?
I had the wrong impression that I could do that with a simple table layout and using Tiles or <c:import> or <jsp:include>
I am new to JSP and web design in general.
Thanks again for the help.
# 5
I think so.
For example, take a look at how the API menu functions:
http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html
You click on the left menu item, and it loads items on the right hand side in an HTML frame.
Another option is, instead of including pages in a frame or in div tags, you could include the menu itself on each JSP page.
So for example say you have index.jsp , then use c:import or jsp:include to include the entire menu JSP on each JSP page.
And use context relative paths for each menu item.
Context relative paths always begin with a / and they are relative to your application's context.
If your application is deployed at http://localhost:port/ , your context is /
Search on Google for "navigational menu struts" , you'll see some examples for your particular case.