Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 0 - Pages: 1  
  Click to reply to this thread Reply

CeWolf in Spring

At 7:45 AM on Dec 18, 2006, Alex Baranov wrote:

As SourceForge.com claims, Cewolf is a “tag library for charts of all kinds. It enables every JSP to easily embed chart images. It can be used by any web applications running in a servlet container.”

Indeed, it is very simple to use and very powerful in any kind of web application. Integrating Cewolf with Spring won’t take a lot of time as well.

To start working with Cewolf you should read a quite short tutorial on project’s site http://cewolf.sourceforge.net . It describes the basics: how to configure web.xml file, what libraries must be included into project.

Now, as you followed all those steps you have working diagram on your web page. But this diagram shows static random values. Now you probably want to fill it with real values that are retrieved for example from database.

Let’s say that you use standard model of building your web-application:

 

Controller -------> Service1 ---------> Object1DAO

| \---> Object2DAO

\----> Service2

\---------------> Object3DAO

 

Services and DAO objects are beans that configured in your context configuration file. You retrieve them in your controller (whether you use Struts or Spring MVC or smth. else).

In order to use services in your DatasetProducer (to fill diagram with real data) you should define it as a bean in your Spring context configuration file:

<bean id="yourDatasetProducer" class="your.package.YourDatasetProducer">

<property name="service1">

<ref bean="service1"/>

</property>

</bean>

Then you can retrieve it in your controller (the same procedure as you use while retrieving services or other beans from Spring context). All Spring beans by default are singletons. We do not need to change that option for yourDatasetProducer bean.

Change example from the tutorial of http://cewolf.sourceforge.net so that our DatasetProducer will be retrieved from session and not created on-the-fly:

1)       change .jsp:

<jsp:useBean id="pageViews" scope=”session” class=" your.package.YourDatasetProducer "/>
<cewolf:chart
id="line"
title="Page View Statistics"
type="line"
xaxislabel="Page"
yaxislabel="Views">
<cewolf:data>
<cewolf:producer id="pageViews"/>
</cewolf:data>
</cewolf:chart>
<p>
<cewolf:img chartid="line" renderer="cewolf" width="400" height="300"/>
<P>

2)       in your controller put yourDatasetProducer bean (retrieved from Spring application contex) into the session:

request.getSession().setAttribute("pageViews", yourDatasetProducer);

 

And that’s it.

Alex Baranov , Software Developer, Itransition Software, Belhard Group JSC

 


thread.rss_message