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

Responding to clicks


Displaying a nice flash chart is great, but allowing the user to interact with it is even better. In this recipe, we will see how to integrate the OFC and Wicket so that the Wicket component knows when the chart has been clicked:

Getting ready

Let's get started by implementing the basic chart component. To keep things simple the Chart will serve static data defined in the Chart.data.template file.

  1. Implement the Chart component. Refer to Chart.java in the code bundle and to the first recipe in this chapter.

  2. Add the Chart component to a page:

    HomePage.java

    // for markup see HomePage.html in the code bundle
    public class HomePage extends WebPage {
       public HomePage() {
          add(new Chart("chart);   }
    }

How to do it...

  1. Tell the chart to invoke a specific JavaScript function when the chart is clicked:

    Chart.data.template

    {
       "bg_colour": "#FFFFFF"
       ,"elements": [ 
          { "type": "line", 
             "dot-style":{ "on-click":"${onclick}" },
             "values": [ 1,2,4,8,5,4,3...