Every RAP application can host it's own static resources, like documents, scripts, images, or CSS-files. These can then be used for favicon, splash-screen, images in markup, within a browser widget, with the JavaScriptLoader or in any JavaScript-based custom widget. It is not necessary to register images used by CSS theming.
There are multiple ways to register a resource, with the main difference beeing the time and place the registration happens.
application.addResource( "foo/icon.png", new ResourceLoader() { @Override public InputStream getResourceAsStream( String resourceName ) throws IOException { return this.getClass().getClassLoader().getResourceAsStream( "resources/icon.png" ); } } );
<extension point="org.eclipse.rap.ui.resources"> <resource class="my.project.resources.IconResource"> </resource> </extension>
ResourceManager resourceManager = RWT.getResourceManager(); if( !resourceManager.isRegistered( "foo/icon.png" ) ) { InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream( "resources/icon.png" ); try { resourceManager.register( resourceName, inputStream ); } finally { inputStream.close(); } }
Important: To use the resource on the client (e.g. in a browser widget or the JavaScriptLoader), is it necessary to know it's public URL from the clients point of view. (The favicon in the application configuration/branding is an exception, here the path from the registration can be used). This information is in all cases provided by the ResourceManager:
String src = RWT.getResourceManager().getLocation( "foo/icon.png" );