All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.butterfaces.handler.ButterFacesResource Maven / Gradle / Ivy

There is a newer version: 3.5.0
Show newest version
package org.butterfaces.handler;

import javax.faces.application.Resource;

/**
 * Simple {@link javax.faces.application.ResourceWrapper} to add a prevent cache that resets resources after deployeing
 * a new artifact.
 */
public class ButterFacesResource extends javax.faces.application.ResourceWrapper {

	// current revision
    private static final long REVISION = System.currentTimeMillis();
	
	private Resource resource;

	public ButterFacesResource(Resource resource) {
		this.resource = resource;
	}

	@Override
	public Resource getWrapped() {
		return this.resource;
	}

	@Override
    public String getRequestPath() {
        String requestPath = resource.getRequestPath();

        if(requestPath.contains("?")) {
            requestPath = requestPath + "&preventCache=" + REVISION;
        }else{
            requestPath = requestPath + "?preventCache=" + REVISION;
        }
            
        return requestPath;
    }

	@Override
	public String getContentType() {
		return getWrapped().getContentType();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy