Package javax.faces.application

Examples of javax.faces.application.ResourceHandler


            setScriptAsRendered(context);
            return;
        }
        // Since we've now determined that it's not in the page, we need to add it.

        ResourceHandler handler = context.getApplication().getResourceHandler();
        Resource resource = handler.createResource(name, library);
        ResponseWriter writer = context.getResponseWriter();
        writer.write('\n');
        writer.startElement("script", null);
        writer.writeAttribute("type", "text/javascript", null);
        writer.writeAttribute("src", ((resource != null) ? resource.getRequestPath() : ""), null);
View Full Code Here


     * @return the encoded path to the image source
     */
    public static String getImageSource(FacesContext context, UIComponent component, String attrName) {

        String resName = (String) component.getAttributes().get("name");
        ResourceHandler handler = context.getApplication().getResourceHandler();
        if (resName != null) {
            String libName = (String) component.getAttributes().get("library");
            Resource res = handler.createResource(resName, libName);
            if (res == null) {
                if (context.isProjectStage(ProjectStage.Development)) {
                    String msg = "Unable to find resource " + (libName == null ? "" : libName + ", ") + resName;
                    context.addMessage(component.getClientId(context),
                                       new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                        msg,
                                                        msg));
                }
                return "RES_NOT_FOUND";
            } else {
              String requestPath = res.getRequestPath();
              return context.getExternalContext().encodeResourceURL(requestPath);
            }
        } else {
           
            String value = (String) component.getAttributes().get(attrName);
            if (value == null || value.length() == 0) {
                return "";
            }
            if (handler.isResourceURL(value)) {
                return value;
            } else {
                value = context.getApplication().getViewHandler().
                      getResourceURL(context, value);
                return (context.getExternalContext().encodeResourceURL(value));
View Full Code Here

        List<String> contractsList = facesContext.getResourceLibraryContracts();
        Assert.assertFalse(contractsList.contains("yellow"));
        Assert.assertTrue(contractsList.contains("blue"));
        Assert.assertFalse(contractsList.contains("red"));
       
        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
       
        ViewResource resource1 = resourceHandler.createViewResource(facesContext, "/panel.xhtml");
        Assert.assertNotNull(resource1);
        Assert.assertTrue(resource1.getURL().toString().contains("panel.xhtml"));
       
        Resource resource2 = resourceHandler.createResource("myjs.js", "mylib");
        Assert.assertNotNull(resource2);
       
        tearDownRequest();
    }
View Full Code Here

                dispenser.getStateManagerIterator(),
                application.getStateManager());
        _callInjectAndPostConstruct(stateManager);
        application.setStateManager(stateManager);

        ResourceHandler resourceHandler = ClassUtils.buildApplicationObject(ResourceHandler.class,
                dispenser.getResourceHandlerIterator(),
                application.getResourceHandler());
        _callInjectAndPostConstruct(resourceHandler);
        application.setResourceHandler(resourceHandler);
View Full Code Here

        }

        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
            Resource compositeComponentResourceWrapped = resourceHandler.createResourceFromId(resourceId);
            if (compositeComponentResourceWrapped != null)
            {
                Resource compositeComponentResource
                        = new CompositeResouceWrapper(compositeComponentResourceWrapped);
                ComponentConfig componentConfig = new ComponentConfigWrapper(cfg,
View Full Code Here

        final Map<String, Object> attributes = component.getAttributes();
        final String resourceName = (String) attributes.get(JSFAttr.NAME_ATTR);
        if (resourceName != null && (resourceName.length() > 0))
        {

            final ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
            final Resource resource;
           
            final String libraryName = (String) component.getAttributes().get(JSFAttr.LIBRARY_ATTR);
            if ((libraryName != null) && (libraryName.length() > 0))
            {
                resource = resourceHandler.createResource(resourceName, libraryName);
            }
            else
            {
                resource = resourceHandler.createResource(resourceName);   
            }
           
            if (resource == null)
            {
                // If resourceName/libraryName are set but no resource created -> probably a typo,
View Full Code Here

        final Map<String, Object> attributes = component.getAttributes();
        final String resourceName = (String) attributes.get(JSFAttr.NAME_ATTR);
        if (resourceName != null && (resourceName.length() > 0))
        {

            final ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
            final Resource resource;
           
            final String libraryName = (String) component.getAttributes().get(JSFAttr.LIBRARY_ATTR);
            if ((libraryName != null) && (libraryName.length() > 0))
            {
                resource = resourceHandler.createResource(resourceName, libraryName);
            }
            else
            {
                resource = resourceHandler.createResource(resourceName);   
            }
           
            if (resource == null)
            {
                // If resourceName/libraryName are set but no resource created -> probably a typo,
View Full Code Here

      throws ServletException, IOException {

    FacesContextHelper helper = new FacesContextHelper();
    try {
      FacesContext facesContext = helper.getFacesContext(getServletContext(), request, response);
      ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
      resourceHandler.handleResourceRequest(facesContext);
    } finally {
      helper.releaseIfNecessary();
    }
  }
View Full Code Here

    }
    return null;
  }

  private void handleResourceRequest(FacesContext facesContext, ResourceRequest request, ResourceResponse response) throws IOException {
    ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
    String resourceName = request.getParameter(FACES_RESOURCE);
    String libraryName = request.getParameter("ln");
    int statusCodeNotFound = HttpStatus.NOT_FOUND.value();
    if (isResourceExcluded(facesContext, resourceName)) {
      response.setProperty(ResourceResponse.HTTP_STATUS_CODE, String.valueOf(statusCodeNotFound));
View Full Code Here

            FacesContext context = FacesContext.getCurrentInstance();
            String libraryName = getCompositeComponentLibraryName(this.ns);
            if (null != libraryName) {
                String ccName = localName + ".xhtml";
                // PENDING: there has to be a cheaper way to test for existence
                ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
                ccResource = resourceHandler.
                        createResource(ccName, libraryName);
            }
        }
        return ccResource;
    }
View Full Code Here

TOP

Related Classes of javax.faces.application.ResourceHandler

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.