You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ms...@gre.ac.uk on 2009/09/15 14:27:17 UTC
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 ?
Re: Simple faces display page
Posted by Kito Mann <ki...@virtua.com>.
Hello,
You should probably just download the entire sample -- as the tutorial
shows, the JSP by itself is enough.
---
Kito D. Mann -- Author, JavaServer Faces in Action
http://twitter.com/kito99 http://twitter.com/jsfcentral
JSF 2 Seminar Oct 6th: http://www.regonline.com/jsf2seminar
JSF Summit Conference Dec 1st-4th in Orlando: http://www.jsfsummit.com
http://www.JSFCentral.com - JavaServer Faces FAQ, news, and info
+1 203-404-4848 x3
On Tue, Sep 15, 2009 at 8:27 AM, <ms...@gre.ac.uk> wrote:
> 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 ?
>
>
>
>
Re: Simple faces display page
Posted by Richard Yee <ri...@gmail.com>.
Neither technology requires the other. Try finding tutorials on JSF or
Hibernate. You might also look into Seam and Spring. Spring has
Hibernate template classes and also integration with JSF.
-Richard
On Thu, Sep 17, 2009 at 2:01 AM, <ms...@gre.ac.uk> wrote:
> ----------------------------------------------------------
> |Thanks a million Richard. You have been a lifesaver. **** |
> ----------------------------------------------------------
>
> Do you know where i can pick up more usefull (jsf + hibernate ) tutorial.
>
>
>
>
> Quoting Richard Yee <ri...@gmail.com>:
>
>> Each time you refresh the page, you are adding the rows again to the
>> existing list in getPerInfoAll. You should put the assignment of
>> perInfoAll = new ArrayList() inside the method instead of at the class
>> level.
>>
>> -R
>>
>> On Wed, Sep 16, 2009 at 5:36 PM, <ms...@gre.ac.uk> wrote:
>> > Cheers Richard. This now works fine... however when i try to use the table
>> from
>> > the woodstock basic the table shows two of everything. as below :
>> > (the standard table works fine)
>> > __________________________________________________________________________
>> >
>> > Unique Id Unique Id
>> >
>> > UserName UserName
>> > PassWord
>> > 3 Zied Zied
>> > 4 Samuel Samuel
>> > 5 Rednose testing
>> > 6 sam sam
>> > 7 Balvinder freedom
>> > 8 red blue
>> > 28 Deepak Kumar
>> > 29 Name Pass
>> > 30 Shiraz Kumar
>> > 31 West Coast
>> > 32 south Coast
>> > 3 Zied Zied
>> > 4 Samuel Samuel
>> > 5 Rednose testing
>> > 6 sam sam
>> > 7 Balvinder freedom
>> > 8 red blue
>> > 28 Deepak Kumar
>> > 29 Name Pass
>> > 30 Shiraz Kumar
>> > 31 West Coast
>> > 32 south Coast
>> >
>> > ________________________________________________________________________
>> > this is the code
>> >
>> > version="2.1" xmlns:f="http://java.sun.com/jsf/core"
>> > xmlns:h="http://java.sun.com/jsf/html"
>> xmlns:jsp="http://java.sun.com/JSP/Page"
>> > xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
>> > <jsp:directive.page contentType="text/html;charset=UTF-8"
>> pageEncoding="UTF-8"/>
>> > <f:view>
>> > <webuijsf:page id="page1">
>> > <webuijsf:html id="html1">
>> > <webuijsf:head id="head1">
>> > <webuijsf:link id="link1"
>> url="/resources/stylesheet.css"/>
>> > </webuijsf:head>
>> > <webuijsf:body id="body1" style="-rave-layout: grid">
>> > <webuijsf:form id="form1">
>> > <webuijsf:table augmentTitle="false" id="table1"
>> > style="left: 168px; top: 96px; position: absolute; width: 450px"
>> title="Current
>> > Users" width="450">
>> > <webuijsf:tableRowGroup id="tableRowGroup1"
>> > sourceData="#{tableBean.perInfoAll}" sourceVar="currentRow">
>> > <webuijsf:tableColumn headerText="Unique
>> Id"
>> > id="tableColumn1" sort="uid">
>> > <webuijsf:staticText id="staticText1"
>> > text="#{currentRow.value['uid']}"/>
>> > </webuijsf:tableColumn>
>> > <webuijsf:tableColumn headerText="UserName"
>> > id="tableColumn2" sort="name">
>> > <webuijsf:staticText id="staticText2"
>> > text="#{currentRow.value['name']}"/>
>> > </webuijsf:tableColumn>
>> > <webuijsf:tableColumn headerText="PassWord"
>> > id="tableColumn3" >
>> > <webuijsf:staticText id="staticText3"
>> > text="#{currentRow.value['pass']}"/>
>> > </webuijsf:tableColumn>
>> > </webuijsf:tableRowGroup>
>> > </webuijsf:table>
>> > </webuijsf:form>
>> > </webuijsf:body>
>> > </webuijsf:html>
>> > </webuijsf:page>
>> > </f:view>
>> > </jsp:root>
>> >
>> >
>> > uoting Richard Yee <ri...@gmail.com>:
>> >
>> >> Remove the rows attribute from your h:dataTable tag or set it to 0
>> >> (rows="0")
>> >> This is what you currently have:
>> >> <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." >
>> >>
>> >> This is the documentation for the rows attribute:
>> >> rows (must evaluate to int) The number of rows to display, starting
>> >> with the one identified by the "first" property. If this value is set
>> >> to zero, all available rows in the underlying data model will be
>> >> displayed.
>> >>
>> >> This explains why only 4 rows are displayed.
>> >>
>> >> -Richard
>> >>
>> >>
>> >>
>> >>
>> >> On Wed, Sep 16, 2009 at 10:11 AM, Richard Yee <ri...@gmail.com>
>> >> wrote:
>> >> > Are you using a debugger? Did you check the size of the list returned
>> >> > by getperInfoAll()?
>> >> >
>> >> > -R
>> >> >
>> >> > On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
>> >> >> Quoting Richard Yee <ri...@gmail.com>:
>> >> >> Cheers Richard, you woul be amazed how much difference changing the
>> case
>> >> made.
>> >> >> However now i get the contents but not all
>> >> >> _________________________________________________________________
>> >> >> the table
>> >> >>
>> >> >> +-----+-----------+---------+
>> >> >> | 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.00 sec)
>> >> >> ____________________________________________________________
>> >> >> the result(without html)
>> >> >> This is The liset of all existing users
>> >> >> UserId User Name User Pass
>> >> >> 3 Zied Zied
>> >> >> 4 Samuel Samuel
>> >> >> 5 Rednose testing
>> >> >> 25 sam sam
>> >> >> The End
>> >> >>
>> >> >> ____________________________________________________________________-
>> >> >>
>> >> >>
>> >> >>> I suggest using a debugger if you are not already doing so to step
>> >> >>> through the call to getPerInfoAll method. Verify that it is reading
>> >> >>> all of the rows and returning a list of all of the rows.
>> >> >>>
>> >> >>> In the code below, you should use #{item.name} and #{item.pass}
>> >> >>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing
>> the
>> >> >>> name of the getUID method to getUid
>> >> >>> Also, the JDBC code should have a finally clause to close. the
>> >> resources.
>> >> >>>
>> >> >>> -R
>> >> >>>
>> >> >>> <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>
>> >> >>>
>> >> >>>
>> >> >>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
>> >> >>> > Quoting Tommy Pham <to...@yahoo.com>:
>> >> >>> >
>> >> >>> >> ----- Original Message ----
>> >> >>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
>> >> >>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
>> >> >>> >> > 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: "ms953@gre.ac.uk"
>> >> >>> >> > > > To: users@myfaces.apache.org
>> >> >>> >> > > > 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
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>> >
>> >> >>>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >
>> >>
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>
Re: Simple faces display page
Posted by ms...@gre.ac.uk.
----------------------------------------------------------
|Thanks a million Richard. You have been a lifesaver. **** |
----------------------------------------------------------
Do you know where i can pick up more usefull (jsf + hibernate ) tutorial.
Quoting Richard Yee <ri...@gmail.com>:
> Each time you refresh the page, you are adding the rows again to the
> existing list in getPerInfoAll. You should put the assignment of
> perInfoAll = new ArrayList() inside the method instead of at the class
> level.
>
> -R
>
> On Wed, Sep 16, 2009 at 5:36 PM, <ms...@gre.ac.uk> wrote:
> > Cheers Richard. This now works fine... however when i try to use the table
> from
> > the woodstock basic the table shows two of everything. as below :
> > (the standard table works fine)
> > __________________________________________________________________________
> >
> > Unique Id Unique Id
> >
> > UserName UserName
> > PassWord
> > 3 Zied Zied
> > 4 Samuel Samuel
> > 5 Rednose testing
> > 6 sam sam
> > 7 Balvinder freedom
> > 8 red blue
> > 28 Deepak Kumar
> > 29 Name Pass
> > 30 Shiraz Kumar
> > 31 West Coast
> > 32 south Coast
> > 3 Zied Zied
> > 4 Samuel Samuel
> > 5 Rednose testing
> > 6 sam sam
> > 7 Balvinder freedom
> > 8 red blue
> > 28 Deepak Kumar
> > 29 Name Pass
> > 30 Shiraz Kumar
> > 31 West Coast
> > 32 south Coast
> >
> > ________________________________________________________________________
> > this is the code
> >
> > version="2.1" xmlns:f="http://java.sun.com/jsf/core"
> > xmlns:h="http://java.sun.com/jsf/html"
> xmlns:jsp="http://java.sun.com/JSP/Page"
> > xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
> > <jsp:directive.page contentType="text/html;charset=UTF-8"
> pageEncoding="UTF-8"/>
> > <f:view>
> > <webuijsf:page id="page1">
> > <webuijsf:html id="html1">
> > <webuijsf:head id="head1">
> > <webuijsf:link id="link1"
> url="/resources/stylesheet.css"/>
> > </webuijsf:head>
> > <webuijsf:body id="body1" style="-rave-layout: grid">
> > <webuijsf:form id="form1">
> > <webuijsf:table augmentTitle="false" id="table1"
> > style="left: 168px; top: 96px; position: absolute; width: 450px"
> title="Current
> > Users" width="450">
> > <webuijsf:tableRowGroup id="tableRowGroup1"
> > sourceData="#{tableBean.perInfoAll}" sourceVar="currentRow">
> > <webuijsf:tableColumn headerText="Unique
> Id"
> > id="tableColumn1" sort="uid">
> > <webuijsf:staticText id="staticText1"
> > text="#{currentRow.value['uid']}"/>
> > </webuijsf:tableColumn>
> > <webuijsf:tableColumn headerText="UserName"
> > id="tableColumn2" sort="name">
> > <webuijsf:staticText id="staticText2"
> > text="#{currentRow.value['name']}"/>
> > </webuijsf:tableColumn>
> > <webuijsf:tableColumn headerText="PassWord"
> > id="tableColumn3" >
> > <webuijsf:staticText id="staticText3"
> > text="#{currentRow.value['pass']}"/>
> > </webuijsf:tableColumn>
> > </webuijsf:tableRowGroup>
> > </webuijsf:table>
> > </webuijsf:form>
> > </webuijsf:body>
> > </webuijsf:html>
> > </webuijsf:page>
> > </f:view>
> > </jsp:root>
> >
> >
> > uoting Richard Yee <ri...@gmail.com>:
> >
> >> Remove the rows attribute from your h:dataTable tag or set it to 0
> >> (rows="0")
> >> This is what you currently have:
> >> <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." >
> >>
> >> This is the documentation for the rows attribute:
> >> rows (must evaluate to int) The number of rows to display, starting
> >> with the one identified by the "first" property. If this value is set
> >> to zero, all available rows in the underlying data model will be
> >> displayed.
> >>
> >> This explains why only 4 rows are displayed.
> >>
> >> -Richard
> >>
> >>
> >>
> >>
> >> On Wed, Sep 16, 2009 at 10:11 AM, Richard Yee <ri...@gmail.com>
> >> wrote:
> >> > Are you using a debugger? Did you check the size of the list returned
> >> > by getperInfoAll()?
> >> >
> >> > -R
> >> >
> >> > On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
> >> >> Quoting Richard Yee <ri...@gmail.com>:
> >> >> Cheers Richard, you woul be amazed how much difference changing the
> case
> >> made.
> >> >> However now i get the contents but not all
> >> >> _________________________________________________________________
> >> >> the table
> >> >>
> >> >> +-----+-----------+---------+
> >> >> | 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.00 sec)
> >> >> ____________________________________________________________
> >> >> the result(without html)
> >> >> This is The liset of all existing users
> >> >> UserId User Name User Pass
> >> >> 3 Zied Zied
> >> >> 4 Samuel Samuel
> >> >> 5 Rednose testing
> >> >> 25 sam sam
> >> >> The End
> >> >>
> >> >> ____________________________________________________________________-
> >> >>
> >> >>
> >> >>> I suggest using a debugger if you are not already doing so to step
> >> >>> through the call to getPerInfoAll method. Verify that it is reading
> >> >>> all of the rows and returning a list of all of the rows.
> >> >>>
> >> >>> In the code below, you should use #{item.name} and #{item.pass}
> >> >>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing
> the
> >> >>> name of the getUID method to getUid
> >> >>> Also, the JDBC code should have a finally clause to close. the
> >> resources.
> >> >>>
> >> >>> -R
> >> >>>
> >> >>> <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>
> >> >>>
> >> >>>
> >> >>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
> >> >>> > Quoting Tommy Pham <to...@yahoo.com>:
> >> >>> >
> >> >>> >> ----- Original Message ----
> >> >>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> >> >>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
> >> >>> >> > 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: "ms953@gre.ac.uk"
> >> >>> >> > > > To: users@myfaces.apache.org
> >> >>> >> > > > 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
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>> >
> >> >>>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>
> >> >
> >>
> >
> >
> >
> >
> >
>
Re: Simple faces display page
Posted by Richard Yee <ri...@gmail.com>.
Each time you refresh the page, you are adding the rows again to the
existing list in getPerInfoAll. You should put the assignment of
perInfoAll = new ArrayList() inside the method instead of at the class
level.
-R
On Wed, Sep 16, 2009 at 5:36 PM, <ms...@gre.ac.uk> wrote:
> Cheers Richard. This now works fine... however when i try to use the table from
> the woodstock basic the table shows two of everything. as below :
> (the standard table works fine)
> __________________________________________________________________________
>
> Unique Id Unique Id
>
> UserName UserName
> PassWord
> 3 Zied Zied
> 4 Samuel Samuel
> 5 Rednose testing
> 6 sam sam
> 7 Balvinder freedom
> 8 red blue
> 28 Deepak Kumar
> 29 Name Pass
> 30 Shiraz Kumar
> 31 West Coast
> 32 south Coast
> 3 Zied Zied
> 4 Samuel Samuel
> 5 Rednose testing
> 6 sam sam
> 7 Balvinder freedom
> 8 red blue
> 28 Deepak Kumar
> 29 Name Pass
> 30 Shiraz Kumar
> 31 West Coast
> 32 south Coast
>
> ________________________________________________________________________
> this is the code
>
> version="2.1" xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page"
> xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
> <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
> <f:view>
> <webuijsf:page id="page1">
> <webuijsf:html id="html1">
> <webuijsf:head id="head1">
> <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
> </webuijsf:head>
> <webuijsf:body id="body1" style="-rave-layout: grid">
> <webuijsf:form id="form1">
> <webuijsf:table augmentTitle="false" id="table1"
> style="left: 168px; top: 96px; position: absolute; width: 450px" title="Current
> Users" width="450">
> <webuijsf:tableRowGroup id="tableRowGroup1"
> sourceData="#{tableBean.perInfoAll}" sourceVar="currentRow">
> <webuijsf:tableColumn headerText="Unique Id"
> id="tableColumn1" sort="uid">
> <webuijsf:staticText id="staticText1"
> text="#{currentRow.value['uid']}"/>
> </webuijsf:tableColumn>
> <webuijsf:tableColumn headerText="UserName"
> id="tableColumn2" sort="name">
> <webuijsf:staticText id="staticText2"
> text="#{currentRow.value['name']}"/>
> </webuijsf:tableColumn>
> <webuijsf:tableColumn headerText="PassWord"
> id="tableColumn3" >
> <webuijsf:staticText id="staticText3"
> text="#{currentRow.value['pass']}"/>
> </webuijsf:tableColumn>
> </webuijsf:tableRowGroup>
> </webuijsf:table>
> </webuijsf:form>
> </webuijsf:body>
> </webuijsf:html>
> </webuijsf:page>
> </f:view>
> </jsp:root>
>
>
> uoting Richard Yee <ri...@gmail.com>:
>
>> Remove the rows attribute from your h:dataTable tag or set it to 0
>> (rows="0")
>> This is what you currently have:
>> <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." >
>>
>> This is the documentation for the rows attribute:
>> rows (must evaluate to int) The number of rows to display, starting
>> with the one identified by the "first" property. If this value is set
>> to zero, all available rows in the underlying data model will be
>> displayed.
>>
>> This explains why only 4 rows are displayed.
>>
>> -Richard
>>
>>
>>
>>
>> On Wed, Sep 16, 2009 at 10:11 AM, Richard Yee <ri...@gmail.com>
>> wrote:
>> > Are you using a debugger? Did you check the size of the list returned
>> > by getperInfoAll()?
>> >
>> > -R
>> >
>> > On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
>> >> Quoting Richard Yee <ri...@gmail.com>:
>> >> Cheers Richard, you woul be amazed how much difference changing the case
>> made.
>> >> However now i get the contents but not all
>> >> _________________________________________________________________
>> >> the table
>> >>
>> >> +-----+-----------+---------+
>> >> | 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.00 sec)
>> >> ____________________________________________________________
>> >> the result(without html)
>> >> This is The liset of all existing users
>> >> UserId User Name User Pass
>> >> 3 Zied Zied
>> >> 4 Samuel Samuel
>> >> 5 Rednose testing
>> >> 25 sam sam
>> >> The End
>> >>
>> >> ____________________________________________________________________-
>> >>
>> >>
>> >>> I suggest using a debugger if you are not already doing so to step
>> >>> through the call to getPerInfoAll method. Verify that it is reading
>> >>> all of the rows and returning a list of all of the rows.
>> >>>
>> >>> In the code below, you should use #{item.name} and #{item.pass}
>> >>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
>> >>> name of the getUID method to getUid
>> >>> Also, the JDBC code should have a finally clause to close. the
>> resources.
>> >>>
>> >>> -R
>> >>>
>> >>> <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>
>> >>>
>> >>>
>> >>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
>> >>> > Quoting Tommy Pham <to...@yahoo.com>:
>> >>> >
>> >>> >> ----- Original Message ----
>> >>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
>> >>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
>> >>> >> > 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: "ms953@gre.ac.uk"
>> >>> >> > > > To: users@myfaces.apache.org
>> >>> >> > > > 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
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>>
>
>
>
>
>
Re: Simple faces display page
Posted by ms...@gre.ac.uk.
Cheers Richard. This now works fine... however when i try to use the table from
the woodstock basic the table shows two of everything. as below :
(the standard table works fine)
__________________________________________________________________________
Unique Id Unique Id
UserName UserName
PassWord
3 Zied Zied
4 Samuel Samuel
5 Rednose testing
6 sam sam
7 Balvinder freedom
8 red blue
28 Deepak Kumar
29 Name Pass
30 Shiraz Kumar
31 West Coast
32 south Coast
3 Zied Zied
4 Samuel Samuel
5 Rednose testing
6 sam sam
7 Balvinder freedom
8 red blue
28 Deepak Kumar
29 Name Pass
30 Shiraz Kumar
31 West Coast
32 south Coast
________________________________________________________________________
this is the code
version="2.1" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<webuijsf:table augmentTitle="false" id="table1"
style="left: 168px; top: 96px; position: absolute; width: 450px" title="Current
Users" width="450">
<webuijsf:tableRowGroup id="tableRowGroup1"
sourceData="#{tableBean.perInfoAll}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Unique Id"
id="tableColumn1" sort="uid">
<webuijsf:staticText id="staticText1"
text="#{currentRow.value['uid']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="UserName"
id="tableColumn2" sort="name">
<webuijsf:staticText id="staticText2"
text="#{currentRow.value['name']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="PassWord"
id="tableColumn3" >
<webuijsf:staticText id="staticText3"
text="#{currentRow.value['pass']}"/>
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>
</webuijsf:table>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:view>
</jsp:root>
uoting Richard Yee <ri...@gmail.com>:
> Remove the rows attribute from your h:dataTable tag or set it to 0
> (rows="0")
> This is what you currently have:
> <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." >
>
> This is the documentation for the rows attribute:
> rows (must evaluate to int) The number of rows to display, starting
> with the one identified by the "first" property. If this value is set
> to zero, all available rows in the underlying data model will be
> displayed.
>
> This explains why only 4 rows are displayed.
>
> -Richard
>
>
>
>
> On Wed, Sep 16, 2009 at 10:11 AM, Richard Yee <ri...@gmail.com>
> wrote:
> > Are you using a debugger? Did you check the size of the list returned
> > by getperInfoAll()?
> >
> > -R
> >
> > On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
> >> Quoting Richard Yee <ri...@gmail.com>:
> >> Cheers Richard, you woul be amazed how much difference changing the case
> made.
> >> However now i get the contents but not all
> >> _________________________________________________________________
> >> the table
> >>
> >> +-----+-----------+---------+
> >> | 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.00 sec)
> >> ____________________________________________________________
> >> the result(without html)
> >> This is The liset of all existing users
> >> UserId User Name User Pass
> >> 3 Zied Zied
> >> 4 Samuel Samuel
> >> 5 Rednose testing
> >> 25 sam sam
> >> The End
> >>
> >> ____________________________________________________________________-
> >>
> >>
> >>> I suggest using a debugger if you are not already doing so to step
> >>> through the call to getPerInfoAll method. Verify that it is reading
> >>> all of the rows and returning a list of all of the rows.
> >>>
> >>> In the code below, you should use #{item.name} and #{item.pass}
> >>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
> >>> name of the getUID method to getUid
> >>> Also, the JDBC code should have a finally clause to close. the
> resources.
> >>>
> >>> -R
> >>>
> >>> <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>
> >>>
> >>>
> >>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
> >>> > Quoting Tommy Pham <to...@yahoo.com>:
> >>> >
> >>> >> ----- Original Message ----
> >>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> >>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
> >>> >> > 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: "ms953@gre.ac.uk"
> >>> >> > > > To: users@myfaces.apache.org
> >>> >> > > > 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
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>>
> >>
> >>
> >>
> >>
> >>
> >
>
Re: Simple faces display page
Posted by Richard Yee <ri...@gmail.com>.
Remove the rows attribute from your h:dataTable tag or set it to 0 (rows="0")
This is what you currently have:
<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." >
This is the documentation for the rows attribute:
rows (must evaluate to int) The number of rows to display, starting
with the one identified by the "first" property. If this value is set
to zero, all available rows in the underlying data model will be
displayed.
This explains why only 4 rows are displayed.
-Richard
On Wed, Sep 16, 2009 at 10:11 AM, Richard Yee <ri...@gmail.com> wrote:
> Are you using a debugger? Did you check the size of the list returned
> by getperInfoAll()?
>
> -R
>
> On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
>> Quoting Richard Yee <ri...@gmail.com>:
>> Cheers Richard, you woul be amazed how much difference changing the case made.
>> However now i get the contents but not all
>> _________________________________________________________________
>> the table
>>
>> +-----+-----------+---------+
>> | 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.00 sec)
>> ____________________________________________________________
>> the result(without html)
>> This is The liset of all existing users
>> UserId User Name User Pass
>> 3 Zied Zied
>> 4 Samuel Samuel
>> 5 Rednose testing
>> 25 sam sam
>> The End
>>
>> ____________________________________________________________________-
>>
>>
>>> I suggest using a debugger if you are not already doing so to step
>>> through the call to getPerInfoAll method. Verify that it is reading
>>> all of the rows and returning a list of all of the rows.
>>>
>>> In the code below, you should use #{item.name} and #{item.pass}
>>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
>>> name of the getUID method to getUid
>>> Also, the JDBC code should have a finally clause to close. the resources.
>>>
>>> -R
>>>
>>> <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>
>>>
>>>
>>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
>>> > Quoting Tommy Pham <to...@yahoo.com>:
>>> >
>>> >> ----- Original Message ----
>>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
>>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
>>> >> > 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: "ms953@gre.ac.uk"
>>> >> > > > To: users@myfaces.apache.org
>>> >> > > > 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
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>>
>>
>>
>>
>>
>>
>
Re: Simple faces display page
Posted by Richard Yee <ri...@gmail.com>.
Are you using a debugger? Did you check the size of the list returned
by getperInfoAll()?
-R
On Wed, Sep 16, 2009 at 3:58 AM, <ms...@gre.ac.uk> wrote:
> Quoting Richard Yee <ri...@gmail.com>:
> Cheers Richard, you woul be amazed how much difference changing the case made.
> However now i get the contents but not all
> _________________________________________________________________
> the table
>
> +-----+-----------+---------+
> | 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.00 sec)
> ____________________________________________________________
> the result(without html)
> This is The liset of all existing users
> UserId User Name User Pass
> 3 Zied Zied
> 4 Samuel Samuel
> 5 Rednose testing
> 25 sam sam
> The End
>
> ____________________________________________________________________-
>
>
>> I suggest using a debugger if you are not already doing so to step
>> through the call to getPerInfoAll method. Verify that it is reading
>> all of the rows and returning a list of all of the rows.
>>
>> In the code below, you should use #{item.name} and #{item.pass}
>> instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
>> name of the getUID method to getUid
>> Also, the JDBC code should have a finally clause to close. the resources.
>>
>> -R
>>
>> <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>
>>
>>
>> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
>> > Quoting Tommy Pham <to...@yahoo.com>:
>> >
>> >> ----- Original Message ----
>> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
>> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
>> >> > 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: "ms953@gre.ac.uk"
>> >> > > > To: users@myfaces.apache.org
>> >> > > > 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
>> >
>> >
>> >
>> >
>> >
>> >
>>
>
>
>
>
>
Re: Simple faces display page
Posted by ms...@gre.ac.uk.
Quoting Richard Yee <ri...@gmail.com>:
Cheers Richard, you woul be amazed how much difference changing the case made.
However now i get the contents but not all
_________________________________________________________________
the table
+-----+-----------+---------+
| 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.00 sec)
____________________________________________________________
the result(without html)
This is The liset of all existing users
UserId User Name User Pass
3 Zied Zied
4 Samuel Samuel
5 Rednose testing
25 sam sam
The End
____________________________________________________________________-
> I suggest using a debugger if you are not already doing so to step
> through the call to getPerInfoAll method. Verify that it is reading
> all of the rows and returning a list of all of the rows.
>
> In the code below, you should use #{item.name} and #{item.pass}
> instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
> name of the getUID method to getUid
> Also, the JDBC code should have a finally clause to close. the resources.
>
> -R
>
> <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>
>
>
> On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
> > Quoting Tommy Pham <to...@yahoo.com>:
> >
> >> ----- Original Message ----
> >> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> >> > To: MyFaces Discussion <us...@myfaces.apache.org>
> >> > 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: "ms953@gre.ac.uk"
> >> > > > To: users@myfaces.apache.org
> >> > > > 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
> >
> >
> >
> >
> >
> >
>
Re: Simple faces display page
Posted by Richard Yee <ri...@gmail.com>.
I suggest using a debugger if you are not already doing so to step
through the call to getPerInfoAll method. Verify that it is reading
all of the rows and returning a list of all of the rows.
In the code below, you should use #{item.name} and #{item.pass}
instead of #{item.Name} and #{item.Pass} I'd also suggest changing the
name of the getUID method to getUid
Also, the JDBC code should have a finally clause to close. the resources.
-R
<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>
On Tue, Sep 15, 2009 at 10:17 AM, <ms...@gre.ac.uk> wrote:
> Quoting Tommy Pham <to...@yahoo.com>:
>
>> ----- Original Message ----
>> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
>> > To: MyFaces Discussion <us...@myfaces.apache.org>
>> > 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: "ms953@gre.ac.uk"
>> > > > To: users@myfaces.apache.org
>> > > > 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
>
>
>
>
>
>
Re: Simple faces display page
Posted by Tommy Pham <to...@yahoo.com>.
--- On Tue, 9/15/09, ms953@gre.ac.uk <ms...@gre.ac.uk> wrote:
> From: ms953@gre.ac.uk <ms...@gre.ac.uk>
> Subject: Re: Simple faces display page
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Date: Tuesday, September 15, 2009, 12:17 PM
> Quoting Tommy Pham <to...@yahoo.com>:
>
> > ----- Original Message ----
> > > From: "ms953@gre.ac.uk"
> <ms...@gre.ac.uk>
> > > To: MyFaces Discussion <us...@myfaces.apache.org>
> > > 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: "ms953@gre.ac.uk"
> > > > > To: users@myfaces.apache.org
> > > > > 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");
Try this instead of the line above:
DriverManager.getConnection("jdbc:mysql://localhost:3306/red","root","root").newInstance();
> 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
>
Re: Simple faces display page
Posted by ms...@gre.ac.uk.
Quoting Tommy Pham <to...@yahoo.com>:
> ----- Original Message ----
> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> > To: MyFaces Discussion <us...@myfaces.apache.org>
> > 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: "ms953@gre.ac.uk"
> > > > To: users@myfaces.apache.org
> > > > 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
Re: Simple faces display page
Posted by Tommy Pham <to...@yahoo.com>.
----- Original Message ----
> From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> To: MyFaces Discussion <us...@myfaces.apache.org>
> 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: "ms953@gre.ac.uk"
> > > To: users@myfaces.apache.org
> > > 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?
Re: Simple faces display page
Posted by ms...@gre.ac.uk.
I did not mean struts i meant faces. Sorry for the confusion
Quoting Tommy Pham <to...@yahoo.com>:
> ----- Original Message ----
> > From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> > To: users@myfaces.apache.org
> > 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...
>
>
Re: Simple faces display page
Posted by Tommy Pham <to...@yahoo.com>.
----- Original Message ----
> From: "ms953@gre.ac.uk" <ms...@gre.ac.uk>
> To: users@myfaces.apache.org
> 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...