org.loom.action.support
Class ResourcesAction

java.lang.Object
  extended by org.loom.action.AbstractAction
      extended by org.loom.action.support.ResourcesAction
All Implemented Interfaces:
Action

@SSLPolicy(value=DO_NOT_MODIFY)
public class ResourcesAction
extends AbstractAction

Retrieves a static resource, such as a javascript/css file. It will set the ETag as the MD5 of the response contents.


Field Summary
static java.lang.String BUNDLE
          the resource bundle name
static java.lang.String MD5
          the name of the md5 GET parameter
static java.lang.String RESOURCE
          the name of the resource GET parameter.
 
Constructor Summary
ResourcesAction()
           
 
Method Summary
 CacheControl cacheCssResource()
           
 CacheControl cacheMessagesRepository()
          If a MD5 attribute has been passed and it's the same of the actual MessageRepository contents, set the response to cache forever.
 CacheControl cacheResource()
           
 Resolution getCssResource()
           
 Resolution getJsMessagesRepository()
          Converts the MessagesRepository instance to a javascript JSON presentation.
 Resolution getResource()
          If Config.development = false, retrieves an entire concatenated bundle and returns it gzipped (if the browser supports gzip).
 
Methods inherited from class org.loom.action.AbstractAction
addError, addError, addError, addMessage, error, error, forward, forward, forwardWithLocale, getContext, getMessagesRepository, getParam, getPropertyAsString, getRequest, getResponse, getSession, getSession, hasAnyError, hasAnyError, info, json, redirect, redirect, redirect, redirect, send, send, send, setContext, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

public static final java.lang.String RESOURCE
the name of the resource GET parameter. This parameter is informational for the user (to see the script name in the browser), and will never be used by the server for security reasons

See Also:
Constant Field Values

BUNDLE

public static final java.lang.String BUNDLE
the resource bundle name

See Also:
Constant Field Values

MD5

public static final java.lang.String MD5
the name of the md5 GET parameter

See Also:
Constant Field Values
Constructor Detail

ResourcesAction

public ResourcesAction()
Method Detail

cacheMessagesRepository

@Cache(on="getJsMessagesRepository")
public CacheControl cacheMessagesRepository()
If a MD5 attribute has been passed and it's the same of the actual MessageRepository contents, set the response to cache forever. If no MD5 GET parameter has been passed, use it as ETag as usual.


getJsMessagesRepository

@Event(defaultEvent=true)
public Resolution getJsMessagesRepository()
Converts the MessagesRepository instance to a javascript JSON presentation. If the provided MD5 parameter is the same of the current one, the response will be set to cache forever.

Returns:
a javascript version of the MessagesRepository for this locale

cacheResource

@Cache(on="getResource")
public CacheControl cacheResource()
                           throws java.io.IOException
Throws:
java.io.IOException

getResource

public Resolution getResource()
                       throws java.io.FileNotFoundException
If Config.development = false, retrieves an entire concatenated bundle and returns it gzipped (if the browser supports gzip).

Returns:
the requested resource, gzipped if supported by the client
Throws:
java.io.FileNotFoundException

cacheCssResource

@Cache(on="getCssResource")
public CacheControl cacheCssResource()
                              throws java.io.IOException
Throws:
java.io.IOException

getCssResource

public Resolution getCssResource()
                          throws java.io.IOException
Returns:
images referenced from the CSS file
Throws:
java.io.IOException