question on pieChart

UI Components for JSF
Post Reply
leffe
Posts: 8
Joined: 09 Nov 2009, 17:20
Location: Belgium

09 Nov 2009, 18:01

hello all

i was trying to make the pieChart example availbale in my page; but i got the message "variable can not be resolved" from myEclipse. the warning message lines is colored by red. i can visit the page, but the pie chart did not displayed. can anyone find the errors in my project? any replys are deeply appriciated. thanks!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>this is my first primeFaces project</title>
<p:resources/>
</head>
<body>
<p>
this is my first primeFaces project
<p:pieChart value="#{showPicture.sales}" var="sale"
categoryField="#{sale.brand}"
dataField="#{sale.amount}"/>

</p>
</body>
</html>

my face-config.xml file is

<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-f ... ig_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>showPicture</managed-bean-name>
<managed-bean-class>com.vub.showPicture.bean.ShowPicture</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>

my web.xml file is

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.ui.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resources/*</url-pattern>
</servlet-mapping>
<!--end of basic primeFaces configuration -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

the java domain file is

public class Sale {
private String brand;
private int amount;
public Sale(){
}
public Sale(String brand, int amount) {
this.brand = brand;
this.amount = amount;
}
//getters and setters
}

the java bean is

public class ShowPicture {
private List<Sale> sales;
public ShowPicture() {
sales = new ArrayList<Sale>();
sales.add(new Sale("Brand 1", 540));
sales.add(new Sale("Brand 2", 325));
sales.add(new Sale("Brand 3", 702));
sales.add(new Sale("Brand 4", 421));
}
public List<Sale> getSales() {
return sales;
}
}

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Nov 2009, 18:07

Welcome to forum,

Can you try,

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:view contentType="text/html">
<head>
<title>this is my first primeFaces project</title>
<p:resources/>
<style type="text/css">
.pie {
 width:500px;
 height:350px;
}
</style>
</head>
<body>
<p>
this is my first primeFaces project
<p:pieChart value="#{showPicture.sales}" var="sale"
categoryField="#{sale.brand}"
dataField="#{sale.amount}" styleClass="pie"/>
</p>
</body>
</f:view>
</html>

leffe
Posts: 8
Joined: 09 Nov 2009, 17:20
Location: Belgium

09 Nov 2009, 18:31

thanks cagatay.civici. i change my xhtml code instead of yours, but the warning message is still there "sale can not be resovled", and i visit the page, i still did not get the pie chart.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Nov 2009, 18:44

Who gives that error? browser?

leffe
Posts: 8
Joined: 09 Nov 2009, 17:20
Location: Belgium

09 Nov 2009, 18:53

acturally, it is not an error message, it is a warning message, the message is given by compiler, at the line of
<p:pieChart value="#{showPicture.sales}" var="sale" categoryField="#{sale.brand}" dataField="#{sale.amount}" styleClass="pie" />
the message is "sale can not be resolved". i checked out my faces-config.xml and java bean, i did not see any error.

leffe
Posts: 8
Joined: 09 Nov 2009, 17:20
Location: Belgium

12 Nov 2009, 17:40

i found the problem that the bean did not feed the data to the <p:pieChart> tag. :D :D :D :D :D

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests