i inherited struts2/jsp webapp , have few problems , wondering if structured/layered out correctly or not. after logging in user @ homescreen 'dashboard' :
<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 user clicks on menu item (pseudo) code executed :
$(..menuitem..).click(function(index,o) { $("#selectedmenuitem").val(menuitemid); // 'submit' main frame load content jsp through action formhomepage.target="contentframe"; formhomepage.submit(); }); the homepage action reads "selectedmenuitem' struts variable, , returns result struts.xml maps correct jsp, projectlist.jsp or userlist.jsp. 'homepage' header/footer/left menu stays in browser , middle content in iframe replaced contect user wanted. think reasonable i've read how iframes should avoided if possible. 1 problem structure has posed in question wrote : action name/url name in debuggers using struts 2
another issue chrome debugger not refresh jsp/javascript source file when user clicks menu item. if put debugger; statement in $(window).load(); use breakpoint, shows random place in original dashboard source file, not file/javascript executing. chrome cache disabled, debugger refuses load new source file.
so how struts/jsps supposed layed out , structured? there better way iframes load content 'section' of page? assume full page refreshes should avoided more efficient. , why cant chrome debugger handle properly?
there's no need use iframe load content. can use ajax if want stay on page , update content in result div.
<div id="resultdiv" class="center"> initial content </div> the script
$(..menuitem..).click(function(index,o) { $("#selectedmenuitem").val(menuitemid); // 'submit' form load content resultdiv on jsp through action $.post($("form").attr("action"), $("form").serialize(),function(result) { $("resultdiv").html(result); }); });
Comments
Post a Comment