public
Last active

  • Download Gist
ItemListActionBean.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
public Resolution findByName() {
logger.debug("*** in findByName()");
Session sess = org.stripesbook.quickstart.util.DAO.getSession();
if (filter != null && filter.length() > 0) {
items = sess.createCriteria(Item.class)
.add(Restrictions.ilike("name", filter+"%"))
.list();
}
logger.debug("*** after filter");
return new ForwardResolution(LIST);
}
item_list.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
function filterItems(field, url) {
$.get(url,
{ 'filter': $(field).val(),
'_eventName': 'findByName'
},
function(data) {
$('#item_table').html(data);
}
);
}
 
function ajaxLink(link, update) {
$.get(link, function(data) {
$(update).html(data);
$(update).show();
});
return false;
}
item_list.jsp
Java Server Pages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
<%@ include file="/WEB-INF/jsp/common/taglibs.jsp" %>
 
<s:layout-render name="/WEB-INF/jsp/common/layout.jsp" title="Found Items" currectSection="ItemList">
 
<s:layout-component name="head">
<script type="text/javascript" src="${contextPath}/script/jquery-1.3.2.min.js" ></script>
<script type="text/javascript" src="${contextPath}/script/item_list.js" ></script>
</s:layout-component>
 
<s:layout-component name="body">
<div id="item_table">
<div>Found Items</div>
<s:url var="url" beanclass="org.stripesbook.quickstart.action.ItemListActionBean"/>
Item Filter: <input type="text" onkeyup="filterItems(this, '${url}');"/><br/>
 
<d:table name="${actionBean.items}" id="item" requestURI="" defaultsort="1"
pagesize="30" sort="list" defaultorder="descending">
 
<d:column title="Date Found" sortProperty="dateFound" sortable="true" >
<fmt:formatDate type="date" dateStyle="full" value="${item.dateFound}" />
</d:column>
 
<d:column title="Name" sortable="true">
<s:link beanclass="org.stripesbook.quickstart.action.ItemDetailActionBean">
<s:param name="item" value="${item.id}"/>
${item.name}
</s:link>
</d:column>
 
<d:column title="City" property="cityId" sortable="true" />
<d:column title="State" property="stateId" sortable="true" />
 
<d:column title="Picture" sortable="true">
<c:if test="${item.imageExists}">
x
</c:if>
</d:column>
</d:table>
</div>
</s:layout-component>
</s:layout-render>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.