aspose file tools*
The moose likes JSF and the fly likes datatable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "datatable problem" Watch "datatable problem" New topic
Author

datatable problem

Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
Hi,

I am trying to display data using datatables. I have tried the examples given in coreservlets but its not working for me. The table data is not populating. The page is not even calling the getter method.
The jsp file:
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE>Fruit Sales</TITLE>
<LINK REL="STYLESHEET"
HREF="./css/styles.css"
TYPE="text/css">
</HEAD>
<BODY>
<CENTER>
<TABLE BORDER=5>
<TR><TH CLASS="TITLE">Fruit Sales By Quarter</TH></TR>
</TABLE>
<H2>Apples and Oranges</H2>

<h:dataTable value="#{salesBean.yearlySales}" var="quarterlySales" border="1">
<h:column>
<f:verbatim>$</f:verbatim>
<hutputText value="quarterlySales.apples"/>
</h:column>


<h:column>
<f:verbatim>$</f:verbatim>
<hutputText value="#{quarterlySales.oranges}"/>
</h:column>

</h:dataTable>

</CENTER>
</BODY></HTML>


</f:view>

The bean: SalesBean
package coreservlets;

import java.util.ArrayList;

public class SalesBean {
private double apples = 0.0, oranges = 0.0;
private ArrayList yearlySales;

public SalesBean() {
public SalesBean(double apples, double oranges) {
setApples(apples);
setOranges(oranges);
}

public double getApples() { return(apples); }

public void setApples(double apples) {
this.apples = apples;
}

public double getOranges() { return(oranges); }

public void setOranges(double oranges) {
this.oranges = oranges;
}

public ArrayList getYearlySales() {
yearlySales = new ArrayList();
yearlySales.add(new SalesBean(100.22, 200.32));
yearlySales.add(new SalesBean(300.44, 400.55));
yearlySales.add(new SalesBean(500.66, 600.77));
yearlySales.add(new SalesBean(700.88, 800.99));
return(yearlySales);
}

}


my faces-config entry is: <managed-bean>
<managed-bean-name>salesBean</managed-bean-name>
<managed-bean-class>
coreservlets.SalesBean
</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

can anyone please tell me where I am going wrong?


Free Mock tests Interview questions
Ghaith Rabadi
Greenhorn

Joined: Oct 28, 2007
Posts: 15
the problem in <hutputText value="quarterlySales.apples"/>
it must be <hutputText value="#{quarterlySales.apples}"/>
Smitha H Rao
Ranch Hand

Joined: Oct 20, 2007
Posts: 50
I have corrected that line. But still I face same problem.. . can anyone please help me..
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536

public SalesBean() {
public SalesBean(double apples, double oranges) {
setApples(apples);
setOranges(oranges);
}

looks like you are missing a closing parenthesis for the no-args constructor.


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datatable problem