Package de.xima.fc.common.faces
Class DevResource
- java.lang.Object
-
- javax.faces.application.ViewResource
-
- javax.faces.application.Resource
-
- javax.faces.application.ResourceWrapper
-
- de.xima.fc.common.faces.DevResource
-
- All Implemented Interfaces:
javax.faces.FacesWrapper<javax.faces.application.Resource>
- Direct Known Subclasses:
DevResource
public class DevResource extends javax.faces.application.ResourceWrapper
A resource meant only for development. It reads the resource directly from the file system and makes sure it is never cached. This is useful especially for transpiled JavaScript or CSS files that change while the server is running.To enable this feature, you must start formcycle with the
dev
mode profile:- Faces development stage must be set to Production
- The system property
de.xima.fc.dev_mode
must be set to true.
To use this feature, you must add either
dev-path
ordev-path-base
as a URL parameter to a Faces resource URL.dev-path
points directly to the path of the file on the file system,dev-path-base
appends the path of the Faces resource to the base URL. The path may be relative, in which case it is resolved against the value of the system property- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description DevResource(javax.faces.application.Resource wrapped, String devPath)
DevResource(javax.faces.application.Resource wrapped, String devPath, String devPathBase)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getInputStream()
String
getRequestPath()
boolean
userAgentNeedsUpdate(javax.faces.context.FacesContext context)
static javax.faces.application.Resource
wrap(javax.faces.application.Resource resource, String devPath)
Wraps the resource with the dev path, if dev mode is enabled.
-
-
-
Constructor Detail
-
DevResource
public DevResource(javax.faces.application.Resource wrapped, String devPath)
- Parameters:
wrapped
- Original compressed resource for which a development resource exists.devPath
- Path to the development resource on the file system.
-
DevResource
public DevResource(javax.faces.application.Resource wrapped, String devPath, String devPathBase)
- Parameters:
wrapped
- Original compressed resource for which a development resource exists.devPath
- Path to the development resource on the file system, required.devPathBase
- Base path for the development resource, may be empty. Added to imports in the resource's content, e.g.@import "..."
in CSS files.
-
-
Method Detail
-
getInputStream
public InputStream getInputStream() throws IOException
- Overrides:
getInputStream
in classjavax.faces.application.ResourceWrapper
- Throws:
IOException
-
getRequestPath
public String getRequestPath()
- Overrides:
getRequestPath
in classjavax.faces.application.ResourceWrapper
-
userAgentNeedsUpdate
public boolean userAgentNeedsUpdate(javax.faces.context.FacesContext context)
- Overrides:
userAgentNeedsUpdate
in classjavax.faces.application.ResourceWrapper
-
wrap
public static javax.faces.application.Resource wrap(javax.faces.application.Resource resource, String devPath)
Wraps the resource with the dev path, if dev mode is enabled.- Parameters:
resource
- Resource to wrap.devPath
- Dev path with the dev resource.- Returns:
- A wrapped dev resource.
-
-