• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DisplayTag Probelm.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 125
1
Clojure Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"vishal TR", please check your private messages immediately.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this below
 
Vishal Maga
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, its working..
Just i need to see how to make image appear on the screen.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of displaying the image file you can try the text option. Try the style sheet in this example. Display tag
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic