This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

cewolf - passing data to jsp

 
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>
 
Rancher
Posts: 43011
76
  • 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
Posts: 43011
76
  • 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.
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!