jsp - Jquery struts2 getting results meanwhile typing the search -
i've been trying last 2 days make search method, meanwhile i'm typing, want see different available results search (in iterator). example: have different products in bbdd , want user check them, searching.
i have tryed autocompleter , getting param term in action, after that, when modify list products, results in iterator don't change.
products_user.jsp
<html> <s:url var="remoteurl" action="products"></s:url> <sj:autocompleter href="%{remoteurl}" label="search product name" list="products" name="product_auto" listkey="name" /> <ul> <s:iterator value="products"> <li> <p> <s:text name="text.name"/> <s:property value="name"/> <s:url id="detalles" action="editproducts"> <s:param name="id_product"><s:property value="id"/></s:param> </s:url> <a href="<s:property value="%{detalles}"/>"> <s:text name="field.details"/> </a> </p> </li> </s:iterator> </ul> showproducts action
public string execute() throws exception{ daofactory sqlfactory; sqlfactory = daofactory.getdaofactory(daofactory.sql); productdao productdao = sqlfactory.getproductdao(); products = productdao.get_all_products(); if(term!=null){ (int = 0; < products.size(); i++) { if (stringutils.startswith(products.get(i).getname().tolowercase(), term.tolowercase())) { products_aux.add(products.get(i)); } } } return "success"; }
i have tryed way couldn't refresh results meanwhile user typing, hope give me hint, thanks!
Comments
Post a Comment