wood burning stoves
The moose likes Struts and the fly likes Datagrid in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Datagrid in Struts 2" Watch "Datagrid in Struts 2" New topic

Datagrid in Struts 2

rahulJ james
Ranch Hand

Joined: Oct 03, 2008
Posts: 123
I am developing a web application using struts 2 framework and with apache-tomcat 5.x..

I would like to know how to use datagrid in jsp using struts 2 or Is there any alternate way to display the dynamic datas from a database in a table represntation
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


If you want to display date into jsp page first define one list and through query get result and set into list variable.

with this variable list just iterate list variable. For Example.

for list define

private List<user> user= userDelegator.getuser();

this is with Struts2 + hibernate getuser gives user list then iterate like.

getUser mathod call

List<user> userlist = session.createCriteria(User.class).list();
return userlist;

<s:iterator value="user">
<s:text name="userName" />
<s:text name="userEmail" />
<s:a href="edituser.action?id=%{id}">Edit</s:a>

here userName and userEmail is Hibernate DTO name which gives you to value of user name and Email.

Nishan Patel.

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
I agree. Here's the link: http://aspose.com/file-tools
subject: Datagrid in Struts 2
It's not a secret anymore!