• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cewolf - passing data to jsp

 
Surya Ram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using the cewolf example code(PageViewCountData class) to create a chart.
The chart comes up good in a jsp.
I am having problem to pass a value(pageCount in the below code) back to the same jsp but show it outside of the chart.

Any help is greatly appreciated. Thanks!

Here is the java code -
public class PageViewCountData implements DatasetProducer, CategoryToolTipGenerator, CategoryItemLinkGenerator, Serializable {

private static final Log log = LogFactory.getLog(PageViewCountData.class);

/**
* Produces some random data.
*/
public Object produceDataset(Map params) throws DatasetProduceException {

log.debug("producing data.");
DefaultCategoryDataset dataset = new DefaultCategoryDataset(){

/**
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();

log.debug(this +" finalized.");
}
};
int pageCount=5;

for (int series = 0; series < vec3.size(); series ++) {

for (int i = 0; i < 30; i++) {
dataset.addValue(Integer.parseInt(vec2.elementAt(i).toString()), vec3.elementAt(series).toString(), vec1.elementAt(i).toString().substring(4,9));
// System.out.println("***"+vec2.elementAt(i).toString()+"***"+vec3.elementAt(series).toString()+"***"+vec1.elementAt(i));
}
}
return dataset;
}


//Here is the jsp
<jsp:useBean id="pageViews" class="de.laures.cewolf.example.PageViewCountData"/>
<cewolf:chart id="line" title="Stats" type="line" xaxislabel="Dates" yaxislabel="Stats">
<cewolf:data>
<cewolf:producer id="pageViews"/>
</cewolf:data>
</cewolf:chart>
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The produceDataset method is called when the image is generated - which is long after the JSP has run. So whatever value you have in that method can't be used in the JSP.

But since the value doesn't seem to change, maybe the PageViewCountData class can set it as a request attribute - which would make it accessible to the JSP.
 
Surya Ram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You! for the reply.

Actually I am accessing the DB to get the value of pageCount (so this value is based on the query to db)in produceDataset method of PageViewCountData class.

Is there a way to pass it to the same jsp but show it outside of the chart.


 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the code you posted doesn't seem to use pageCount, I'd move the logic to retrieve the value from the DB to whichever servlet handles this JSP page - then you can set it as a request attribute.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic