concept resource in category gwt

appears as: resources, resource, resources, resource
GWT in Action

This is an excerpt from Manning's book GWT in Action.

If you don’t inherit the correct module, the GWT compiler will throw a “did you forget to inherit a module?” error. You can even get this error in standard GWT if you use functionality outside the standard aspects, for example, client bundles. An efficient way to manage resources, which is discussed in chapter 5, requires you to explicitly inherit the Resources module (we’ll cover these as and when needed).

18.7.6. Accessing resources through the ResourceOracle

You can find resources—text files, images, and so on—within a compilation context through the ResourceOracle. It’s created from the context parameter passed to the generate method of the generator:

ResourceOracle resrs = context.getResourcesOracle();

With access to the ResourceOracle the generator can now look up resources, as shown in the following listing.

Listing 18.10. Using the methods in the ResourceOracle to access resources

You can do three things with a ResourceOracle , each revolving around the path to a resource. The path is the location of a resource in some arbitrary namespace, constructed using / between name elements and ending in a valid filename. At you can see a path to a GWTinAction.pdf file that’s in a com.manning.gwt.client package.

Getting a resource is one thing, but what can you do with it once you have it? A generator can request three bits of information: the last-modified timestamp (getLastModified method), the location (getLocation method), and the path (getPath method). The location is a URL-like location of the resource that’s valid only if the resource is truly available via a URL.