Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Pie Chart display based on submitted selection usin

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All,

I need Urgent help in JSF, RichFaces, Jfree chart. I am new for these technolgies.

I am having form which is having some drop down menu and one submit button. Suppose I selected 'A' from dropdown this selection pass to Java code based on which DAO layer will return row counts. This count is passed in Jfree Pie chart method to create a Pie chart. In UI I need to display this chart in second Panel of same Dropdown page. UI is developed with RichFaces. Code is as below for UI:

<h:form id="txnDashBoardDataForm" style="border:0">
<rich:panel>

<div align="center">
<a4j:commandButton value="View Chart" id="searchButton"
styleClass="controlButtonActive"
reRender="resultPanelId"
actionListener="#{dashboardCtrl.loadTxnCount}"
oncomplete="if(#{facesContext.maximumSeverity != null}){
#{rich:component('InfoMessagePopUp')}.show();
}else{ } " />
</div>
</rich:panel>

<a4j:outputPanel id="resultPanelId" ajaxRendered="true">
<rich:panel>

<a4j:mediaOutput style="width:200px;height:200px;" element="img"
cacheable="false" session="true" createContent="#{dashboardCtrl.loadTxnCounts}"
mimeType="image/gif" />
</rich:panel>
</a4j:outputPanel>


In above code in <a4j:commandButton> I used reRender attribute, which is having same id as given in <a4j:outputPanel id="resultPanelId" ajaxRendered="true">. If I am first time loading page then I can see Pie chart is coming on UI this is due to <a4j: mediaOutput createContent attribute where I am calling the function which is calling Chart creation function. But if I am selection one item from Drop down and then submitting the Form chart is not getting displayed. Though in console I can see Graph method is called, but then some Decode error is coming :

ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
javax.faces.FacesException: Error decode resource data

Please help me to know how I can display Pie chart after submitting form. As of now I only know that richfaces mediaOutput I can use. Please help on urgent basis.
 
Saloon Keeper
Posts: 25824
184
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanchm Shikha!

What is the scope of your backing bean (dashboardCtrl)? It should be at least View scope, since Request Scope is useless.

You should be able to find additional stack trace information in your logs that can help in figuring this out.
 
Shikha bajpai
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

that is having "session" scope. Actually we want to implement the code in following way using JSF, Ricfaces:

1. User will see dropdown list in UI. He will select one iten from Dropdown and submit the selection.
2. This selection will be saved in dashboardCtrl bean, which is further used by DAO layer to get the count of records.
3. These count of records need to pass in CHart method which in turn return the graph.

In below code during time of Hit to VIew chart button selected data is getting stored in dashBoardCtrl bean and then in mediaOutput calling the Chart creator method.

This is required to refresh the chart based on User selected values, that is te reason used Re-render. Now don't know this is the correct way or not

Please help me to know.

 
Tim Holloway
Saloon Keeper
Posts: 25824
184
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We really do need a more complete stack trace.

As far as generating 2 different sub-Views from a single Model object, that's one of the advantages of using an MVC design (such as JSF). The decoupling of the Views and Models via the Controllers means that you don't have (sub)View-specific code or properties in the model.
 
reply
    Bookmark Topic Watch Topic
  • New Topic