Another question on RichFaces integration (+ a little more)

UI Components for JSF
Post Reply
unlud
Posts: 6
Joined: 06 May 2009, 05:04

13 May 2009, 06:57

Hi,

First thanks for your project, this looks great!

I start to use the charts and I have two questions:

1/ I wanted to use the columnChar but could not have it working. I tried with exactly the same backing beans as the ones for the lineChart which works. I just replace lineChart with columnChar in the following code and I have an exception saying that a collection cannot be cast to a String. So is there something special to do regarding the columnChar? Is the use similar in both or is there something specific for columnChar?

Code: Select all

         
<p:lineChart value="#{chartBean.nbCreatePerPeriods}" var="nbCreatePeriod" xfield="#{nbCreatePeriod.date}">
     <p:chartSeries label="Nb" value="#{nbCreatePeriod.nb}" />
</p:lineChart>
2/ I would like to update my chart based on a click coming from a richfaces button. I looked through the documentation but did not see anything obvious. Do you know a way to do that?

Thanks a lot!

Ludovic

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

13 May 2009, 11:37

1) Yes lineChart and columnChart usage are identical, barChart is different since it needs yfield instead of xfield.

Please give the line number causing the exception.

2) I'd suggest using PrimeFaces button instead of a4j button.

Code: Select all

<p:button value="Update Chart" async="true" update="chartIdHere" />

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

13 May 2009, 11:45

This should just work;

Code: Select all

<p:columnChart value="#{chartBean.nbCreatePerPeriods}" var="nbCreatePeriod" xfield="#{nbCreatePeriod.date}">
     <p:chartSeries label="Nb" value="#{nbCreatePeriod.nb}" />
</p:columnChart >

unlud
Posts: 6
Joined: 06 May 2009, 05:04

14 May 2009, 05:49

Hi Catagay,

here is the code I have in my page:

Code: Select all

         <p:columnChart value="# { chartBean.nbCreatePerPeriods}" var="nbCreatePeriod"  xfield="#{nbCreatePeriod.date}" >  
               <p:chartSeries label="Nb" value="#{nbCreatePeriod.nb}" />  
         </p:columnChart> 
        
        <!--   
         <p:lineChart value="#{chartBean.nbCreatePerPeriods}" var="nbCreatePeriod" xfield="#{nbCreatePeriod.date}">
				<p:chartSeries label="Nb" value="#{nbCreatePeriod.nb}" />
		 </p:lineChart>
		 -->
the commented one works fine.

The first one (column) throws an exception:

Code: Select all

java.lang.String cannot be cast to java.util.Collection at org.primefaces.ui.component.chart.column.ColumnChartRenderer.encodeLocalData(ColumnChartRenderer.java:65) at org.primefaces.ui.component.chart.column.ColumnChartRenderer.encodeChartScript(ColumnChartRenderer.java:49) at org.primefaces.ui.component.chart.BaseChartRenderer.encodeEnd(BaseChartRenderer.java:38) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892) at javax.faces.render.Renderer.encodeChildren(Renderer.java:137) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.richfaces.renderkit.TabRendererBase.encodeChildren(TabRendererBase.java:113) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:285) at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:280) at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812) at 
I may give the backing bean if you want but as it works with the lineChart I don't think there is something wrong with it.

thanks
Ludovic

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

14 May 2009, 10:59

You have a whitespace after #

Code: Select all

<p:columnChart value="# { chartBean.nbCreatePerPeriods}" ...
instead it should be;

Code: Select all

<p:columnChart value="#{chartBean.nbCreatePerPeriods}" ...

unlud
Posts: 6
Joined: 06 May 2009, 05:04

18 May 2009, 00:14

thanks a lot! that fixes the issue.

Ludovic

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

18 May 2009, 00:52

Glad it works, basically "# { " is interpreted as a string and not evaluated properly.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests