Results 1 to 15 of 15
- 09-21-2011, 08:34 PM #1
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Problem using a list with piechart
Hi guys, i'm having some trouble to create a piechart from a list
primefaces version 3.0.M3
tomcat version 7.0
this is the error i'm getting
this is where i call the listJava Code:Sep 20, 2011 6:33:59 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException SEVERE: Error Rendering View[/restrito/acao.xhtml] java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.primefaces.model.chart.PieChartModel
and this is the listJava Code:<ui:composition> <h:panelGrid width="100%"> <h:form id="graficosCarteira"> <h:panelGrid columns="2" width="100%"> <p:panel header="Composição carteira em % de quantidade" toggleable="true" toggleSpeed="500"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.acao.quantidade}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> <p:panel header="Composição carteira em % de valor" toggleable="true" toggleSpeed="500" style="margin-left:+10px;"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.total}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> </h:panelGrid> </h:form> </h:panelGrid> </ui:composition>
Can anyone tell me what i'm doing wrong?Java Code:public List<AcaoVirtual> getLista() { FacesContext context = FacesContext.getCurrentInstance(); ContextoBean contextoBean = ContextoUtil.getContextoBean(); AcaoRN acaoRN = new AcaoRN(); try { if (this.lista == null) { this.lista = acaoRN.listarAcaoVirtual(contextoBean.getUsuarioLogado()); } } catch (RNException e) { context.addMessage(null, new FacesMessage(e.getMessage())); } return this.lista; }
the AcaoVirtual is here:
Thank you very much.Java Code:public class AcaoVirtual { private Acao acao = new Acao(); private float ultimoPreco; private float total; public Acao getAcao() { return acao; } public void setAcao(Acao acao) { this.acao = acao; } public float getUltimoPreco() { return ultimoPreco; } public void setUltimoPreco(float ultimoPreco) { this.ultimoPreco = ultimoPreco; } public float getTotal() { return total; } public void setTotal(float total) { this.total = total; } }
- 09-22-2011, 12:09 AM #2
Re: Problem using a list with piechart
Where do you cast anything to a PieChartModel?java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.primefaces.model.chart.PieChartModel
- 09-22-2011, 12:19 AM #3
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
- 09-22-2011, 12:24 AM #4
Re: Problem using a list with piechart
Sorry, I'm restricted to java code only. That doesn't look like java.
- 09-22-2011, 12:28 AM #5
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
Hi, Norm, thanks again for the reply
the method who is been called from de JSF (Java Sever Faces) and using the Primefaces Framework, is in the 1st post i made as you can see
and as you can see, there no castsJava Code:public List<AcaoVirtual> getLista() { FacesContext context = FacesContext.getCurrentInstance(); ContextoBean contextoBean = ContextoUtil.getContextoBean(); AcaoRN acaoRN = new AcaoRN(); try { if (this.lista == null) { this.lista = acaoRN.listarAcaoVirtual(contextoBean.getUsuarioLogado()); } } catch (RNException e) { context.addMessage(null, new FacesMessage(e.getMessage())); } return this.lista; }
Thank you.
- 09-22-2011, 12:30 AM #6
Re: Problem using a list with piechart
I still don't see the java code where a variable is cast to a PieChartModel.
Is there generated source code where that happens?
- 09-22-2011, 12:39 AM #7
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
hi, Norm, thanks again.
I'm not sure if i get it.
In any moment a made a cast to piechart, the only place i'm using it, is in the JSF, with the tag i posted
my variables from my class AcaoBean are these ones:
thank you very muchJava Code:private AcaoVirtual selecionada = new AcaoVirtual(); private List<AcaoVirtual> lista = null; private String linkCodigoAcao = null;
and this is my jsf where a create de pieChart
Java Code:<ui:composition> <h:panelGrid width="100%"> <h:form id="graficosCarteira"> <h:panelGrid columns="2" width="100%"> <p:panel header="Composição carteira em % de quantidade" toggleable="true" toggleSpeed="500"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.acao.quantidade}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> <p:panel header="Composição carteira em % de valor" toggleable="true" toggleSpeed="500" style="margin-left:+10px;"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.total}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> </h:panelGrid> </h:form> </h:panelGrid> </ui:composition>Last edited by dennisbf; 09-22-2011 at 12:44 AM.
- 09-22-2011, 01:07 AM #8
Re: Problem using a list with piechart
Does the jsf "code" generate java code that is compiled?
Otherwise where is the "cast" being done?
- 09-22-2011, 01:09 AM #9
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
hi, norm
There is no cast, the JSF is just the view
if i leave the piegraph part on JSF commented, the page opens, if i don't i get this errorLast edited by dennisbf; 09-22-2011 at 01:11 AM.
- 09-22-2011, 01:11 AM #10
Re: Problem using a list with piechart
What happens to this code:
It's not java. Is it converted to java source and compiled?Java Code:<ui:composition> <h:panelGrid width="100%"> <h:form id="graficosCarteira"> <h:panelGrid columns="2" width="100%"> <p:panel header="Composição carteira em % de quantidade" toggleable="true" toggleSpeed="500"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.acao.quantidade}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> <p:panel header="Composição carteira em % de valor" toggleable="true" toggleSpeed="500" style="margin-left:+10px;"> <p:pieChart value="#{acaoBean.lista}" var="acaoVirtual" categoryField="#{acaoVirtual.acao.sigla}" dataField="#{acaoVirtual.total}" width="265px" height="125px" style="estiloGrafico" /> </p:panel> </h:panelGrid> </h:form> </h:panelGrid>
What program does anything with the above code? What does it do with it?
- 09-22-2011, 01:21 AM #11
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
Hi, Norm
This is a part of a Stock page, whre you can see your Stock (from the graph that is not loading), you can add new Stocks, and you have a graph from YahooUtil.
this jsf is called here, wich is the main page for stocks
it is convertedJava Code:<?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" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:composition template="/templates/interna.xhtml"> <ui:define name="titulo"> Cadastro de Ações </ui:define> <ui:define name="corpo"> <h:outputScript target="head"> var estiloGrafico = { padding :20, legend : { display :"right", spacing :10 } }; </h:outputScript> <ui:include src="acao_graficoscarteira.xhtml" /> <br /> <ui:include src="acao_edicao.xhtml" /> <br /> <ui:include src="acao_listagem.xhtml" /> <br /> <ui:include src="acao_graficos.xhtml" /> </ui:define> </ui:composition> </html>
- 09-22-2011, 01:33 AM #12
Re: Problem using a list with piechart
None of that can execute. There is a program that reads it and does ????
- 09-22-2011, 01:35 AM #13
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Re: Problem using a list with piechart
It is a website actually
And the graph suposed to open when you call the page
"localhost:8080/FinanceiroWeb/restrito/acao.jsf"
but, as the page load the graph, i'm getting this error.
- 09-22-2011, 01:52 AM #14
Re: Problem using a list with piechart
It doesn't matter where the file is, there is a program that reads it and does something with it.
- 09-22-2011, 01:54 AM #15
Member
- Join Date
- Sep 2011
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
List problem
By Bulelakes in forum JDBCReplies: 7Last Post: 07-30-2010, 07:51 AM -
piechart not being drawn on a panel
By dataprofiling in forum Java 2DReplies: 1Last Post: 03-27-2010, 11:33 AM -
assignment problem with List<T>
By Newbie666 in forum New To JavaReplies: 11Last Post: 01-21-2010, 12:12 PM -
Array List Problem
By khamuruddeen in forum New To JavaReplies: 1Last Post: 12-22-2007, 08:10 AM -
list problem
By fareez in forum New To JavaReplies: 3Last Post: 06-28-2007, 10:26 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks