Web アプリケーションで JPA と JavaScript で Spring MVC (3.x) を使用しています。JavaScriptを使用したテキストボックスのオートコンプリート機能に関する1つの質問...
1 - DAOImpl レイヤーにある
public List<String> getProjectServiceList()
{
Query query = getEntityManager().createQuery("Select DISTINCT
req.projectServiceName from Request req where req.activeInd=1");
List<String> projectServiceList = query.getResultList();
return projectServiceList;
}
2 - RequestController.java で、モデル属性 projectServiceList を設定しました
List<String> projectServiceList = getRequestService().getProjectServiceList();
model.addAttribute("projectServiceList", projectServiceList);
3 - JSP で、すべての結果を foreach タグ付きの選択ボックスにリストしました
<tr>
<td>Project/Service Name</td>
<td><select name="searchBean.projectServiceName" id="searchBean.projectServiceName" >
<option value="">All</option>
<c:forEach items="${projectServiceList}" var="entry">
<option value="${entry}" ${entry == baseBean.searchBean.projectServiceName
? 'selected' : ''}>${entry}</option>
</c:forEach>
</select>
</td>
</tr>
しかし、私の質問は、Javaスクリプトを使用してオートコンプリートテキストボックスで同じことを行う方法です(すべてのリストを持つjsbにモデル属性「projectServiceList」があります)