Package javax.faces.application

Examples of javax.faces.application.Resource


    public String imageUrl(String resourceName) {
        if ("plain".equals(getName())){
            return "none";
        }
        FacesContext facesContext = FacesContext.getCurrentInstance();
        Resource resource = facesContext.getApplication().getResourceHandler().createResource(resourceName, IMAGE_LIBRARY);

        String resourcePath;
        if (resource != null) {
            resourcePath = resource.getRequestPath();

        } else {
            resourcePath = "RES_NOT_FOUND";
            LOG.warn("Unable to find or serve resource '" + ResourceKey.create(resourceName, IMAGE_LIBRARY) + "'");
        }
View Full Code Here


    private void logMissingResource(FacesContext context, String resourceData) {
        logResourceProblem(context, null, "Resource {0} was not found", resourceData);
    }

    private Resource createCompiledCSSResource(ResourceKey resourceKey) {
        Resource sourceResource = defaultHandler.createResource(resourceKey.getResourceName(), resourceKey.getLibraryName(),
                "text/plain");
        if (sourceResource != null) {
            return new CompiledCSSResource(sourceResource);
        }
View Full Code Here

        if (!checkResult) {
            return null;
        }

        Resource result = null;

        if (Java2DUserResource.class.isAssignableFrom(loadedClass)) {
            Java2DUserResource java2DUserResource = (Java2DUserResource) loadedClass.newInstance();
            result = createResource(java2DUserResource);
        } else if (UserResource.class.isAssignableFrom(loadedClass)) {
View Full Code Here

        if (!checkResult) {
            return null;
        }

        Class<? extends Resource> resourceClass = loadedClass.asSubclass(Resource.class);
        Resource result = (Resource) resourceClass.newInstance();

        return result;
    }
View Full Code Here

            return null;
        }

        String resourceName = resourceKey.getResourceName();

        Resource resource = null;
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

        if (contextClassLoader != null) {
            try {
                Class<?> loadedClass = Class.forName(resourceName, false, contextClassLoader);

                resource = createDynamicUserResourceInstance(loadedClass);
                if (resource == null) {
                    resource = createDynamicResourceInstance(loadedClass);
                }

                if (resource != null) {
                    resource.setResourceName(resourceName);

                    if (parameters != null) {
                        if (resource instanceof BaseResourceWrapper<?>) {
                            BaseResourceWrapper<?> baseResourceWrapper = (BaseResourceWrapper<?>) resource;
View Full Code Here

    private String getMappedPath(FacesContext context) {
        if (resourcePath != null) {
            return resourcePath.toExternalForm();
        } else {
            Resource resource = context.getApplication().getResourceHandler()
                    .createResource(resourceKey.getResourceName(), resourceKey.getLibraryName());
            if (resource == null) {
                return "RESOURCE_NOT_FOUND";
            }
            return getResourcePath(resource);
View Full Code Here

    }

    @Override
    public Resource createResource(String resourceName, String libraryName, String contentType) {
        ResourceKey resourceKey = new ResourceKey(resourceName, libraryName);
        Resource result = resourceFactory.createResource(resourceName, libraryName, contentType);

        if (result != null) {
            FacesContext context = FacesContext.getCurrentInstance();
            Object state = ResourceUtils.saveResourceState(context, result);
            Resource newResource = resourceFactory.createResource(context, new ResourceRequestDataImpl(resourceKey, state));
            if (newResource != null) {
                result = new DynamicResourceWrapper(newResource);
            }
        }
View Full Code Here

            libraryDirs = roots;
        }

        VirtualFile resource = findResource(libraryDirs, resourceName);
        if (resource != null) {
            Resource result = new VFSResource(resource, resource.getRelativePath());

            result.setResourceName(resourceName);
            result.setLibraryName(libraryName);

            if (Strings.isNullOrEmpty(contentType)) {
                result.setContentType(MimetypesFileTypeMap.getDefaultFileTypeMap().getContentType(resourceName));
            } else {
                result.setContentType(contentType);
            }

            return result;
        }
View Full Code Here

    }

    private static LibraryFunction getScriptResource(FacesContext facesContext, Class<?> javaClass) {
        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
        String resourceName = javaClass.getSimpleName() + ".js";
        Resource facesResource = resourceHandler.createResource(resourceName, ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
        if (null != facesResource) {
            final String functionName = firstToLowerCase(javaClass.getSimpleName());
            return new LibraryFunctionImplementation(functionName, resourceName, ORG_RICHFACES_CSV);
        } else {
            return NO_SCRIPT;
View Full Code Here

    @Override
    public Resource createResource(String resourceName, String libraryName,
            String contentType)
    {
        Resource resource = null;
       
        if (contentType == null)
        {
            //Resolve contentType using ExternalContext.getMimeType
            contentType = FacesContext.getCurrentInstance().getExternalContext().getMimeType(resourceName);
View Full Code Here

TOP

Related Classes of javax.faces.application.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.