Quoting Tommy Pham <[email protected]>:
> ----- Original Message ----
> > From: "[email protected]" <[email protected]>
> > To: MyFaces Discussion <[email protected]>
> > Sent: Tuesday, September 15, 2009 8:00:59 AM
> > Subject: Re: Simple faces display page
> >
> > I did not mean struts i meant faces. Sorry for the confusion
> >
> > Quoting Tommy Pham :
> >
> > > ----- Original Message ----
> > > > From: "[email protected]"
> > > > To: [email protected]
> > > > Sent: Tuesday, September 15, 2009 5:27:17 AM
> > > > Subject: Simple faces display page
> > > >
> > > > I have copied the example from
> (http://www.roseindia.net/jsf/data.shtml).
> > > >
> > > > th problem now is that my data.jsp does not show any contents. I am
> using
> > > > struts2
> > > >
> > > > does anyone know why ?
> > >
> > > The link you gave makes no mention of struts in the tutorial...
> > >
> > >
>
> Does your database have any data? Are you getting any errors? Warnings?
>
>
____________________________________________________________________________
Yes i have data in the database
as shown below:
mysql> select * from first;
+-----+-----------+---------+
| UID | NAME | PASS |
+-----+-----------+---------+
| 3 | Zied | Zied |
| 4 | Samuel | Samuel |
| 5 | Rednose | testing |
| 25 | sam | sam |
| 26 | Balvinder | freedom |
| 27 | red | blue |
| 28 | Deepak | Kumar |
| 29 | Name | Pass |
| 30 | Shiraz | Kumar |
| 31 | West | Coast |
| 32 | south | Coast |
+-----+-----------+---------+
11 rows in set (0.11 sec)
_____________________________________________________________________
this is the java code
import java.sql.*;
import java.util.*;
public class User {
Connection con ;
Statement ps;
ResultSet rs;
private List perInfoAll = new ArrayList();
public List getperInfoAll() {
int i = 0;
try
{
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/red","root","root");
ps = con.createStatement();
rs = ps.executeQuery("select * from First");
while(rs.next()){
System.out.println(rs.getInt(1));
perInfoAll.add(new perInfo(rs.getInt(1),rs.getString(2),rs.getString(3)));
i++;
}
}
catch (Exception e)
{
System.out.println("Error Data : " + e.getMessage());
}
return perInfoAll;
}
public class perInfo {
int UID;
String Name;
String Pass;
public perInfo(int UID, String Name,String Pass) {
this.UID = UID;
this.Name = Name;
this.Pass = Pass;
}
public int getUID() {
return UID;
}
public String getName() {
return Name;
}
public String getPass() {
return Pass;
}
}
}
___________________________________________________________________
this is the faces-config.xml
<managed-bean>
<managed-bean-name>tableBean</managed-bean-name>
<managed-bean-class>simplehiber.User</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
___________________________________________________________________
the jsp page
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view><html>
<head>
</head>
<body>
<center>
<br><br><br>
<h:dataTable id="dt1" value="#{tableBean.perInfoAll}" var="item"
bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" rows="4"
width="50%" dir="LTR" frame="hsides" rules="all" summary="This is a JSF code to
create dataTable." >
<f:facet name="header">
<h:outputText value="This is The liset of all existing users" />
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="UserId" />
</f:facet>
<h:outputText style="" value="#{item.UID}" ></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="User Name"/>
</f:facet>
<h:outputText value="#{item.Name}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="User Pass"/>
</f:facet>
<h:outputText value="#{item.Pass}"></h:outputText>
</h:column>
<f:facet name="footer">
<h:outputText value="The End" />
</f:facet>
</h:dataTable><br>
</center>
</body></html></f:view>
__________________________________________________________________
the output(without html)
This is The liset of all existing users
UserId User Name User Pass
3
The End