Julien Viet edited this page Sep 17, 2013 · 17 revisions
Clone this wiki locally

Welcome to the Juzu wiki, will serve as basis for the documentation.

Asset plugin

Issues with current plugin

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

Declaring assets

   @Asset(id="bootstrap", depends={"jquery","bootstrap.css"}),
   @Asset(id="jquery", source="jquery.js"),
   @Asset(id = "bootstrap.css", source = "bootstrap.css")
package myapplication;

Scope assets at a package

package mycontrollers;

Scope assets at a controller class

public class MyController { ... }

Scope assets at a controller method

public Response.View index() { ... }

Asset declaration

Assets are declared with the @Asset annotation contained within an @Assets annotation container:

  • id the asset id, the value is optional and when it is not provided it is deduced from the value. For example @Asset("jquery.js") has id jquery.js
  • depends a list of ids declaring the asset dependencies, empty by default
  • value the asset path, relative to the assets package
  • location declares where the asset physical resource is found, by default as an application asset

Asset usage

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