Chapter 9. Images, CSS, and scripts: working with resources

 

In this chapter:

  • Including images, scripts, and stylesheets using packaged resources
  • Providing downloadable content with dynamic resources
  • Integrating third-party libraries using resources

Up to now, we’ve mainly been talking about components. As powerful as they are, there are some things you can’t do with them. For example, you can’t render PDFs with them, and they don’t provide a direct answer to how images or CSS files should be handled.

This is where Wicket resources come in. Wicket resources are objects that can process requests independently from pages. They typically represent things like images and files (for instance, JavaScript and CSS files); but as you’ll see in this chapter, they aren’t limited to that.

In the first part of this chapter, we’ll look at what we call packaged resources and show how they can be used to develop custom components that ship with their own images and other dependencies. After that, we’ll investigate three ways to use Wicket resources to build functionality for downloading cheese discounts in a file of comma-separated values (CSV). The final part of this chapter examines how you can use Wicket resources to integrate third-party software that generates PDFs, images, and so on.

First, let’s look at a concept you’ll likely be using soon: packaged resources.

9.1. Using packaged resources

9.2. Building export functionality as a resource

9.3. Resources and third-party libraries

9.4. Summary

sitemap