[jQuery] AJAX Tab with Struts2 and SiteMesh
This may be a post for the struts list, but I'll start her. I'm using
Jquery with Struts2 and SiteMesh. My tabs work fine with all my code
on a single JSP. I tried switching to AJAX, but that breaks the OGNL
reference to a list on the second TAB. I set-up a separate namespace
in Struts so that I could exclude the pages from SiteMesh. My tabs
looked like this:
<struts:url var="generalUrl" action="DisplayNeighborhood"
namespace="rpc" method="generalInfo" >
<struts:param name="selectedNeighborhoodId" value="%
{selectedNeighborhoodId}" />
</struts:url>
<struts:url var="streetUrl" action="DisplayNeighborhood"
namespace="rpc" method="listStreets" >
<struts:param name="selectedNeighborhoodId" value="%
{selectedNeighborhoodId}" />
</struts:url>
<struts:url var="propertyUrl" action="DisplayNeighborhood"
namespace="rpc" method="listProperties" >
<struts:param name="selectedNeighborhoodId" value="%
{selectedNeighborhoodId}" />
</struts:url>
<div id="tabs">
<ul>
<li><struts:a href="%{#generalUrl}" ><span>General Information</
span></struts:a></li>
<li><struts:a href="%{#streetUrl}" ><span>Streets</span></
struts:a></li>
<li><struts:a href="%{#propertyUrl}" ><span>Properties</span></
struts:a></li>
</ul>
</div>
Code from the first tab works fine, but the AJAX load of the following
code produces "No Neighborhoods Streets to show." Tab order has no
effect. As I said, if I paste the code below into a tab div tag using
the non-AJAX style, then everything works fine and the list is
displayed. Has anyone else run into this problem?
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/pages/include/taglibs.jspf" %>
<table id="table">
<thead>
<tr>
<th class="sorting">Direction</th>
<th class="sorting">Name</th>
<th class="sorting">Qualifier</th>
</tr>
</thead>
<tbody>
<struts:if test="%{neighborhoodStreets != null &&
neighborhoodStreets.size() > 0}" >
<struts:iterator value="neighborhoodStreets"
id="neighborhoodStreet" status="status">
<tr>
<td style="text-align: center;">
<struts:property value="streetDirection" />
</td>
<td style="text-align: center;"><struts:property
value="streetName" /></td>
<td style="text-align: center;"><struts:property
value="streetQualifier" /></td>
</tr>
</struts:iterator>
</struts:if>
<struts:else ><tr><td colspan="3">No Neighborhoods Streets to
show.</td></tr></struts:else>
</tbody>
</table>
Steve Mitchell
http://www.ByteworksInc.com