I inherited a Struts 2/JSP webapp and have a few problems and am wondering if it is structured/layered out correctly or not. After logging in the user is at a homescreen dashboard
like so :
<s:form action="HomePage" name="formHomePage" method="post">
<s:hidden name="selectedMenuItem" id="selectedMenuItem"/>
<div id="layout">
<!-- HEADER -->
<div class="header" style="position:fixed; z-index:1;">
... Header bar ...
</div>
<!-- LEFT MENU -->
<div class="left">
<h3>Menu</h3>
<li id="dashboard">Dashboard</li>
<li id="projectList">Projects</li>f
<li id="userList">Users</li>
</ul>
</div>
<!-- MAIN CONTENT -->
<div class="center">
<iframe id="ifrmContent" name="contentFrame" src=""> </iframe>
</div>
<!-- FOOTER -->
<div class="footer" style="position:fixed; z-index:1;">
.... Footer bar ...
</div>
</div>
</s:form>
When the user clicks on a menu item this (pseudo) code is executed :
$(..menuItem..).click(function(index,o) {
$("#selectedMenuItem").val(menuItemID);
// 'Submit' this main frame to load the content JSP through the action
formHomePage.target="contentFrame";
formHomePage.submit();
});
The HomePage
action reads the selectedMenuItem
Struts variable, and returns a result that struts.xml
maps to the correct JSP, like ProjectList.jsp
or UserList.jsp
. This HomePage
with header/footer/left menu always stays in the browser and only the middle content in the iframe is replaced by the contect the user wanted. I think this is reasonable but I've read how iframes should be avoided if possible. One problem this structure has was posed in another question I wrote :
Action name/URL name in debuggers using Struts 2
Another issue is that Chrome debugger does not refresh the JSP/javascript source file when the user clicks a menu item. If I put a debugger; statement in $(window).load();
it will use the breakpoint, but it shows a random place in the original dashboard source file, NOT the file/javascript that is actually executing. The Chrome cache is disabled, but the debugger refuses to load the new source file.
So is this how Struts/JSPs are supposed to be layed out and structured? Is there a better way than iframes to load only a content 'section' of the page? I assume full page refreshes should be avoided to be more efficient. And why cant the Chrome debugger handle this properly?