Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
Srikanth Shenoy
Author of Struts Survival Guide : Basics to Best Practices
SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="http://webtools.servehttp.com" target="_blank" rel="nofollow">http://webtools.servehttp.com</a> down for a while...
Originally posted by Vero Couderc:
Hi,
if anybody could help me with the Displaytag as I am trying to make it work for long enough now and Iam not successful on this!!!
Customers.java:
package Mypackage;
import java.sql.*;
public class Customers {
private String company_name;
private String address;
private String address2;
private String city;
public Customers(ResultSet rs){
try{
setCompany_name(rs.getString("company_name"));
setCity(rs.getString("city"));
setAddress2(rs.getString("address2"));
setAddress(rs.getString("address"));
} catch(Exception e){
}
}
public void setCompany_name(String company_name) {
this.company_name = company_name;
}
public String getCompany_name() {
return company_name;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getAddress2() {
return address2;
}
public void setCity(String city) {
this.city = city;
}
public String getCity() {
return city;
}
}
test.jsp:
<%
PreparedStatement prep1 = conn.prepareStatement("select company_name, address, address2, city from customer order by company_name limit " + currentRs + "," + records);
ResultSet rs = prep1.executeQuery();
List customers_list = new ArrayList();
while(rs.next()){
Customers customers = new Customers(rs);
customers_list.add(customers);
}
conn.close();
%>
<display:table name="<%= customers_list %>">
<display:column property="company_name" title="company_name" />
<display:column property="address" title="address"/>
<display:column property="address2" title="address2"/>
<display:column property="city" title="city"/>
</display:table>
I've tried some other ways too and still get stuck!
Originally I have the page working fine with the preparedStatement and the html table displaying the results and the pages numbers etc but I would like to adapt it to better codes, can anyone help please?
Many thanks
Vero
Consider Paul's rocket mass heater. |