aspose file tools*
The moose likes Struts and the fly likes DisplayTag Probelm. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "DisplayTag Probelm." Watch "DisplayTag Probelm." New topic
Author

DisplayTag Probelm.

Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
hi all, i m very much new to struts. in my jsp page i m using display tag to view table from resultset .The code is given below. The result is not getting displayed. Please help.

JSP: CODE
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

<%@ page import= "com.project.web.Search.form.SearchExpBean"%>

<link rel="stylesheet" type="text/css" href="css/displaytagex.css">

<%@ page import="java.util.*"%>
<%
ArrayList mylist = (ArrayList) request.getAttribute("SearchResult");
%>

<display:table name="mylist">
<display:column property="UserID" title="UserID"/>
<display:column property="FirstName" title="FirstName"/>
<display:column property="LastName" title="TelNo"/>
<display:column property="Email" title="Email"/>
</display:table>

BEAN: ExpSearchResultFormBean
private String UserID;
private String FirstName;
private String LastName;
private String TelNo;
private String Email;
private String Comments;
private String Username;
private String Password;



public String getUserID() {
return UserID;
}
public void setUserID(String userID) {
UserID = userID;
}
public String getFirstName() {
return FirstName;
}
public void setFirstName(String firstName) {
FirstName = firstName;
}
public String getLastName() {
return LastName;
}


DAO:
rs = pStmt.executeQuery();
while (rs.next()) {
ExpSearchResultFormBean bean = new ExpSearchResultFormBean();
bean.setUserID(rs.getString(1));
bean.setFirstName(rs.getString(2));
bean.setLastName(rs.getString(3));
bean.setTelNo(rs.getString(4));
bean.setComments(rs.getString(6));
bean.setUsername(rs.getString(7));
bean.setPassword(rs.getString(8));
bean.setEmail(rs.getString(5));

System.out.println("using tags- in DAO");
arr.add(bean);
}
return arr;

in Action:
SearchExpFormGetDAO dao = new SearchExpFormGetDAO();
SearchExpBean formbean = (SearchExpBean ) form;
ArrayList details1 = dao.fetch(formbean);
request.setAttribute("SearchResult", details1);

StrutsConfig:-
<action path="/Search1" name="SearchExpBean"
type="com.project.web.Search.action.SearchExpBeanAction"
scope="request" validate="false" parameter="search"
input="/SearchExpCandidate.jsp">
<forward name="success" path="/SearchExpCandidate.jsp" />

</action>

I think i have given all the details.
When i run the JSP i get "Nothing found to display".

Please help.
waiting for reply. Thnaks in advance.
Michael Swierczek
Ranch Hand

Joined: Oct 07, 2005
Posts: 105
    
    1
I'm no super Struts expert, but since no one else has answered, I'll try to help.

1. Which version of Struts are you using? I'm using 1.3.8, and there were many big changes between Struts 1.x and 2.x. If you're using 2.x, my information may not be useful.

2. When you get 'Nothing found to display', is the entire JSP blank save for that message, or just the table?

3. You did not specify your Struts config form-bean entry. If you don't have one, you need one.

4. When the DAO runs the query, is the System.out.println indicating that any data is found?
Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
Thanks for reply....Please see my comments below


1. Version of Struts =1.9

2. No. i m redirecting it to same page. So on top of the screen it is displaying 'Nothing found to display'. In jsp i have some search parameters. On click of search button i want to show the table.

3. Correct. I have ExpSearchResultFormBean to hold the data as shown above. I have defined both ExpSearchResultFormBean and SearchExpBean in config file.

4. When the DAO runs the query, is the System.out.println indicating 2 records.

i feel i am not providing correct list to display tag. In my list i am having ExpSearchResultFormBean, which is holding all the search result.

Please revert with your comments. Thanks once again.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

"vishal TR", please check your private messages immediately.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
try this below
Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
Thanks for reply,

In DAO code.
Do i need to put dierctly resultset in list as shown below.
try {
pStmt = con.prepareStatement(INSERT);
pStmt.setString(1, totalExp);
rs = pStmt.executeQuery();
arr.add(rs);


} catch (Exception e) {
e.printStackTrace();
}

return arr;

Or it has to be in one more bean as shown in my first post.

When i use result set it is displaying as shown below in my jsp
com.mysql.jdbc.ResultSet@175b7f9

when i add bean to list it is displaying in my jsp
com.mysql.jdbc.ResultSet@175b7f9
com.project.web.Search.form.SearchResultFormBean@ffeef1
com.project.web.Search.form.SearchResultFormBean@aa3518

And i have changed my display part as shown below.
<display:table name="SearchResult">
</display:table>

Note:- I am using displaytag-el.tld.

Please help.

Thanks & Regards
Vishal
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
which one you are using to get records from database. Hibernate or ejb or simple java class.
List and Result Set is different. So after getting your result Set , you need to parse the Result Set into List.
if you add result Set directly into List using list.add(resultset).
you will get resultSet id value as output in jsp(Current result).you cannot get exact value.
So write a logic to convert ResultSet into List.
Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
Thank you. I got the result. It is getting displayed, but without any css applied to it.
Display tage used.
<display:table name="SearchExpResult" export="true" id="row" class="dataTable">
<display:column property="UserID" title="UserID"/>
<display:column property="FirstName" title="FirstName"/>
<display:column property="LastName" title="TelNo"/>
<display:column property="Email" title="Email"/>
</display:table>

and also the export to excel is showing blank sheet.

Please help.
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
To apply CSS style to table, Just go through the below link. And copy the default CSS file and include it in your jsp page.For export to excel also you can get resource hereweb page
Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
Thanks.
Able to do export and paging.
But I am not able to view the tabel as shown in the link. Simple plain text without any border and color. What i have do to make my table view like how it is there in the link.
Please help

i have include the css file in my jsp as shown below
<link rel="stylesheet" type="text/css" href="css/displaytagex.css">

Please help
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
make a separate folder for css files, and also make a separate folder for images.display tag table design having 4 important images, you need to include it in images folder, get the copy of images below
1.arrow.gif 2.arrow_up.png 3.arrow_off.png 4.arrown_domn.png.if you donot get send your code thro mail or private messages
selvaraju sellamuthu
Ranch Hand

Joined: Jun 28, 2007
Posts: 53
make a separate folder for css files, and also make a separate folder for images.display tag table design having 4 important images, you need to include it in images folder, get the copy of images below
1.arrow.gif 2.arrow_up.png 3.arrow_off.png 4.arrown_domn.png.if you donot get send your code thro mail or private messages
Vishal Maga
Greenhorn

Joined: Nov 27, 2007
Posts: 11
Thanks, its working..
Just i need to see how to make image appear on the screen.
Annahita Moshiri
Greenhorn

Joined: May 22, 2008
Posts: 9
Hi! What a great forum! this is my first post here

I had the same problem with display tag and I solved it with the info in this post. But I still have another issue:

When I set the export="true" I get the export list below my table, but the small icons used for the export options are repeated four times!! I don't know why this is happening.

Here's what it look likes:


Anyone can help?
Annahita Moshiri
Greenhorn

Joined: May 22, 2008
Posts: 9
Originally posted by Annahita Moshiri:
Hi! What a great forum! this is my first post here

I had the same problem with display tag and I solved it with the info in this post. But I still have another issue:

When I set the export="true" I get the export list below my table, but the small icons used for the export options are repeated four times!! I don't know why this is happening.

Here's what it look likes:


Anyone can help?



Hey guys it's a background repeat issue. I solved it by adding this to each span.XXX class in the css file:

background-repeat: no-repeat
Nyanas Kandhan
Ranch Hand

Joined: Jan 27, 2009
Posts: 35
Instead of displaying the image file you can try the text option. Try the style sheet in this example. Display tag


regards,
Nyanaskandhan
Ayan Dutta
Ranch Hand

Joined: Oct 16, 2005
Posts: 94
Hi ,
I have faced similar problem recently . After the table loaded correctly with proper coloring of alternate rows etc etc ,
after clicking the link of sorting or prev/next link of pagination the coloring of all rows and pagination were lost .
After banging my head for some time , I had a look at some of the running examples using from internet , which uses struts and display tag together.
What I found out that if the requestURI is mentioned properly , this problem is gone .
In my case it was missing .

I have not drilled down the code of display tag , so I am not sure exactly why it happens like this .
So , if you have something like :
,
correctly , the rendering will be OK and you can get some relief as I got .

Let me know if it works for you guys .

Regards,
Ayan Dutta
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DisplayTag Probelm.
 
Similar Threads
Display Tag pagination
logic :iterator problem can anyone please solve this....
Anyone done a good 'paged' datatable solution for Struts?
Struts2, have to eneter site twice to get the list populated
Displaying a large ResultSet, in multiple HTML pages