Book Image

Apache Wicket Cookbook

By : Igor Vaynberg
Book Image

Apache Wicket Cookbook

By: Igor Vaynberg

Overview of this book

<p>Apache Wicket is one of the most famous Java web application frameworks. Wicket simplifies web development and makes it fun. Are you bored of going through countless pages of theory to find out how to get your web development done? With this book in hand, you don't need to go through hundreds of pages to figure out how you will actually build a web application. You will get practical solutions to your common everyday development tasks to pace up your development activities.</p> <p><i>Apache Wicket Cookbook</i> provides you with information that gets your problems solved quickly without beating around the bush. This book is perfect for you if you are ready to take the next step from tutorials and step into the practical world. It will take you beyond the basics of using Apache Wicket and show you how to leverage Wicket's advanced features to create simpler and more maintainable solutions to what at first may seem complex problems.</p> <p>You will learn how to integrate with client-side technologies such as JavaScript libraries or Flash components, which will help you to build your application faster. You will discover how to use Wicket paradigms to factor out commonly used code into custom Components, which will reduce the maintenance cost of your application, and how to leverage the existing Wicket Components to make your own code simpler.</p>
Table of Contents (18 chapters)
Apache Wicket Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Feeding chart data using a SharedResource


In this recipe, we will see how to feed data to the OFC chart using a SharedResource. The advantage of this technique, over using a component-callback, is that all charts on the page can get their data asynchronously because access to SharedResources is not synchronized to a single thread per page. This will reduce the total time to load the page and make the application feel more responsive. This will make a big difference when we have multiple charts on the page as follows:

Getting ready

Let's get started by implementing the chart by using a component callback to retrieve the data.

  1. Implement StockService that will feed us chart data; see the first recipe for code listing.

  2. Implement the Chart component. Refer to Chart.template and Chart.data.template in the code bundle for the data setup of the chart.

    Chart.java

    public class Chart extends WebComponent
          implements IHeaderContributor, IResourceListener {
    
       public Chart(String id, IModel<String...