我有一个相当简单的用例,
我有一个搜索表单和一个网格
网格应该在 loadSearch.action 上显示一些默认结果。
当用户在搜索表单中输入几个条件并点击提交按钮时,必须在下面的网格中重新加载 ajax 结果。
我通过发布响应获得结果,但无法在网格内显示它们。
这是我的代码
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Search Patient</title>
<sj:head jqueryui="true"/>
</head>
<body>
<s:form id="form" action="search" theme="simple" namespace="/patient/register" cssClass="yform">
<div>
<table>
<tr>
<td>
<s:text name="global.fname"></s:text>
</td>
<td>
<sj:textfield name="firstName"></sj:textfield>
</td>
</tr>
<tr>
<td>
<s:text name="global.lname"></s:text>
</td>
<td>
<sj:textfield name="lastName"></sj:textfield>
</td>
</tr>
</table>
<div>
<sj:a onSuccessTopics="reloadGrid" button="true">Search</sj:a>
</div>
</div>
</s:form>
<div>
<div id="searchResults">
<sjg:grid id="gridtable" caption="Customer Examples"
pager="true" dataType="json" reloadTopics="reloadGrid" formIds="form"
gridModel="patients" rowList="10,15,20" rowNum="15" loadonce="true"
href="%{search}"
rownumbers="true">
<sjg:gridColumn name="userId" index="userID" title="Id"
sortable="true" />
<sjg:gridColumn name="firstName" index="firstName" title="Name"
sortable="true" />
</sjg:grid>
</div>
</div>
</body>
</html>
XML 映射
<action name="loadSearch" class="com.cursive.eclinic.action.PatientAction" method="loadSearch">
<interceptor-ref name="userAgentInterceptor" />
<result name="success">search.jsp</result>
<result name="error">/commons/exception.jsp</result>
</action>
<action name="search" class="com.cursive.eclinic.action.PatientAction" method="search">
<interceptor-ref name="exception"></interceptor-ref>
<interceptor-ref name="prepare"></interceptor-ref>
<interceptor-ref name="modelDriven"></interceptor-ref>
<interceptor-ref name="params"></interceptor-ref>
<interceptor-ref name="userAgentInterceptor" />
<result name="success" type="json">
<param name="includeProperties">
^patients\[\d+\]\.userId,
^patients\[\d+\]\.firstName,
</param>
</result>
</action>