-
Notifications
You must be signed in to change notification settings - Fork 45
Home
Julien Viet edited this page Sep 17, 2013
·
17 revisions
Welcome to the Juzu wiki, will serve as basis for the documentation.
Main issue with current plugin is the lack of granularity of the asset, i.e an asset is served globally or not. To serve an asset it must then be added by the controller in the response object.
- Decouple the asset declaration from the asset serving declaration
- Use a unified asset that encompass both scripts and stylesheets: allow to create dependencies between script and stylesheets
- Make the associated asset source optional
@Application
@Assets({
@Asset(id="bootstrap", depends={"jquery","bootstrap.css"}),
@Asset(id="jquery", source="jquery.js"),
@Asset(id = "bootstrap.css", source = "bootstrap.css")
})
package myapplication;
@WithAssets("bootstrap")
package mycontrollers;
@WithAssets("bootstrap")
public class MyController { ... }
@WithAssets("jquery")
@View
public Response.View index() { ... }
Assets are declared with the @Asset annotation contained within an @Assets annotation container:
-
idthe asset id, the value is optional and when it is not provided it is deduced from the value. For example@Asset("jquery.js")has idjquery.js -
dependsa list of ids declaring the asset dependencies, empty by default -
valuethe asset path, relative to theassetspackage -
locationdeclares where the asset physical resource is found, by default as an application asset
Asset usage is declared on Java program elements:
- controller method
- controller class
- java packages
Asset declarations cascades based on the program element hierarchy.
Asset usage can be declared with the @WithAssets annotation that contains a list of patterns matching the asset ids.
- matching a specific asset:
@WithAssets("jquery") - matching several assets:
@WithAssets("jquery","bootstrap") - matching any assets:
@WithAssets("*")or@WithAssets