if you are using Struts2 it's quit easy.
just return list from you service class,
--------------------------------------------------------------------------------
public List yourmethod() {
Session session = Utils.HibernateUtil.getSessionFactory().openSession();
session.getTransaction().begin();
List list = new ArrayList();
try {
List qry = session.createCriteria(dao-class-name.class).list();
} catch (Exception e) {
}
return list;
}
---------------------------------------------------------------------------------
after getting list ,just iterate them..
public String gridsearchdata() {
Session session = hibernate.HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
try {
gridconst grdcns = new gridconst();
gridservice grdsrv = new gridservice();
gridModel = new ArrayList();
Iterator itr = grdsrv.gridsearch(sr, name, age, address, phoneNo).iterator();
while (itr.hasNext()) {
Griddata obj = (Griddata) itr.next();
gridModel.add(new gridconst(obj.getSr(), obj.getName(), obj.getAge(), obj.getAddress(), obj.getPhoneNo()));
}
} catch (Exception e) {
e.printStackTrace();
session.getTransaction().rollback();
}
return SUCCESS;
}
-----------------------------------------------
batter to use struts2 jquery grid,for struts2 jquery grid download jquery lib form
"http://code.google.com/p/struts2-jquery/downloads/detail?name=struts2-jquery-grid-plugin-2.5.3.jar&can=2&q="
jquery grid code
<sj:head xmlns:sj="#unknown">
<s:url id="ticketgrid" action="ticketaction" namespace="/ticketassigning"/>
<sjg:grid
id="Ticketassigngrid"
caption="Assign Ticket"
dataType="json"
href="%{ticketgrid}"
onSelectRowTopics="rowselect"
formIds="ticketForm"
gridModel="itemlist"
reloadTopics="refreshdgrid"
rownumbers="true"
width="1000"
height="150"
>
<sjg:gridColumn name="idTicketLogid" index="idTicketLogid" title="Ticket No" key="true"/>
<sjg:gridColumn name="loggedby" index="loggedby" title="Logged By" />
<sjg:gridColumn name="loggedDate" index="loggedDate" title="Logged Date" formatter="date"/>
<sjg:gridColumn name="location" index="location" title="Location"/>
<sjg:gridColumn name="idTicketSubCategoryCd" index="idTicketSubCategoryCd" title="Category" width="220"/>
<sjg:gridColumn name="ticketstatuslookup" index="ticketstatuslookup" title="Status" />
<sjg:gridColumn name="ticketPriority" index="ticketPriority" title="Priority" />
<sjg:gridColumn name="assignedTo" index="assignedTo" title="Assigned to"/>
</sjg:grid>