当前位置: 首页>>代码示例>>Java>>正文


Java Resource类代码示例

本文整理汇总了Java中javax.faces.application.Resource的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Resource类属于javax.faces.application包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getInputStream

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Reads the input stream from the wrapped resource, removes {@link #REGEX_BG_IMG background images} and
 * {@link #REGEX_ICON UI icons} and appends the patch loaded from {@link #FONT_AWESOME_CSS_RESOURCE}. If the
 * {@link AbstractResource#PARAM_NAME_APPEND_CSS_RESOURCE} context parameter is set, the contents of that CSS resource
 * will be appended.
 *
 * @return Cleaned and patched CSS.
 *
 * @throws IOException
 */
@Override
public InputStream getInputStream() throws IOException
{
	String css = readInputStream(getWrapped().getInputStream());
	css = css.replaceAll(REGEX_BG_IMG, "");
	css = css.replaceAll(REGEX_ICON, "");
	StringBuilder sb = new StringBuilder(css);

	// Append FontAwesome CSS
	Resource resource = getHandler().createResource(FONT_AWESOME_CSS_RESOURCE);
	sb.append(readInputStream(resource.getInputStream()));

	// Append custom CSS
	appendCss(sb);

	return new ByteArrayInputStream(sb.toString().getBytes(getCharset()));
}
 
开发者ID:jepsar,项目名称:Jepsar-PrimeFaces-Theme,代码行数:28,代码来源:FontAwesomeResource.java

示例2: CombinedResourceInputStream

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Creates an instance of {@link CombinedResourceInputStream} based on the given resources. For each resource, the {@link InputStream}
 * will be obtained and hold in an iterable collection.
 * 
 * @param resources
 *            The resources to be read.
 * @throws IOException
 *             If something fails at I/O level.
 */
public CombinedResourceInputStream(Set<Resource> resources) throws IOException {
    prepareStreaming(resources);

    /* 16.02.2015 Caching added by Stephan Rauh, http://www.beyondjava.net */
    if ("true".equals(Faces.getInitParameter(PARAM_NAME_ACTIVATE_RESOURCE_CACHING))) {
        combinedResource = prepareStreamingFromCache(streamIterator, resources);
        pointer = 0;
        currentStream = null;
    }
    else
    {
        streamIterator.hasNext(); // We assume it to be always true, see also CombinedResource#getInputStream().
        currentStream = streamIterator.next();
    }
    /* 16.02.2015 end of pull request */
}
 
开发者ID:stephanrauh,项目名称:BootsFaces-Examples,代码行数:26,代码来源:CombinedResourceInputStream.java

示例3: prepareStreaming

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Collects the list of Stream that have to be read.
 * @param resources The resources to be read.
 * @throws IOException If something fails at I/O level.
 */
private void prepareStreaming(Set<Resource> resources) throws IOException {
    streams = new ArrayList<>();
    String domainURL = getRequestDomainURL();

    for (Resource resource : resources) {
        InputStream stream;

        try {
            stream = resource.getInputStream();
        } catch (Exception richFacesDoesNotSupportThis) {
            stream = new URL(domainURL + resource.getRequestPath()).openStream();
        }

        streams.add(stream);
        streams.add(new ByteArrayInputStream(CRLF));
    }

    streamIterator = streams.iterator();
}
 
开发者ID:stephanrauh,项目名称:BootsFaces-Examples,代码行数:25,代码来源:CombinedResourceInputStream.java

示例4: createResource

import javax.faces.application.Resource; //导入依赖的package包/类
@Override
public Resource createResource(final String resourceName,
                               final String libraryName) {
  final Resource resource = super.createResource(resourceName,
                            libraryName);
  return resource;

  // if (resource == null || !"primefaces".equals(libraryName)
  //     || !"jquery/jquery.js".equals(resourceName)) {
  //   return resource;
  // }

  // return new ResourceWrapper() {
  //   @Override
  //   public String getRequestPath() {
  //     return "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js";
  //   }

  //   @Override
  //   public Resource getWrapped() {
  //     return resource;
  //   }
  // };
}
 
开发者ID:UniversityOfWuerzburg-ChairCompSciVI,项目名称:ueps,代码行数:25,代码来源:CDNResourceHandler.java

示例5: encodeBegin

import javax.faces.application.Resource; //导入依赖的package包/类
@Override
  public void encodeBegin(FacesContext context) throws IOException {
      Application app = context.getApplication();
      ResourceHandler rh = app.getResourceHandler();
  	ResponseWriter responseWriter = context.getResponseWriter();
Resource h5s = rh.createResource("js/html5shiv.js", C.BSF_LIBRARY);
Resource rjs = rh.createResource("js/respond.js", C.BSF_LIBRARY);

responseWriter.write("<!--[if lt IE 9]>");
responseWriter.startElement("script", null);
responseWriter.writeAttribute("src", h5s.getRequestPath(), null);
responseWriter.endElement("script");
responseWriter.startElement("script", null);
responseWriter.writeAttribute("src", rjs.getRequestPath(), null);
responseWriter.endElement("script");
responseWriter.write("<![endif]-->");
  }
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:18,代码来源:InternalIE8CompatiblityLinks.java

示例6: createResource

import javax.faces.application.Resource; //导入依赖的package包/类
@Override
public Resource createResource(String resourceName, String libraryName)
{
    Resource resource = wrapped.createResource(resourceName, libraryName);

    if (activated && resource != null && libraryName != null && LIBRARY.equals(libraryName))
    {
        if (ProjectStageProducer.getInstance().getProjectStage() == ProjectStage.Development)
        {
            resource = wrapped.createResource(resourceName, LIBRARY_UNCOMPRESSED);
        }
        
        resource = new DeltaSpikeResource(resource, version);
    }

    return resource;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:DeltaSpikeResourceHandler.java

示例7: ReplaceResource

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Calls super and set {@link #findValues} and {@link #replaceValues}.
 *
 * @param wrapped Wrapped resource.
 * @param handler Handler that created this resource.
 *
 * @throws IllegalStateException If no replacement values were set.
 */
public ReplaceResource(Resource wrapped, ResourceHandler handler)
{
	super(wrapped, handler);
	String findValuesParam = getInitParameter(FacesContext.getCurrentInstance(), PARAM_NAME_FIND_VALUES);
	this.findValues = findValuesParam == null ? DEFAULT_FIND_VALUES : findValuesParam;
	this.replaceValues = getInitParameter(FacesContext.getCurrentInstance(), PARAM_NAME_REPLACE_VALUES);
	if (replaceValues == null) {
		throw new IllegalStateException(String.format(ISE_NO_REPLACEMENTS, PARAM_NAME_REPLACE_VALUES));
	}
}
 
开发者ID:jepsar,项目名称:Jepsar-PrimeFaces-Theme,代码行数:19,代码来源:ReplaceResource.java

示例8: AbstractResource

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Wraps the resource and sets {@link #charset} and {@link #appendCssResource}.
 *
 * @param wrapped Wrapped resource.
 * @param handler Handler that created this resource.
 */
public AbstractResource(Resource wrapped, ResourceHandler handler)
{
	this.wrapped = wrapped;
	this.handler = handler;
	String charEncoding = FacesContext.getCurrentInstance().getExternalContext().getResponseCharacterEncoding();
	this.charset = Charset.forName(charEncoding);
	this.appendCssResource = getInitParameter(FacesContext.getCurrentInstance(), PARAM_NAME_APPEND_CSS_RESOURCE);
}
 
开发者ID:jepsar,项目名称:Jepsar-PrimeFaces-Theme,代码行数:15,代码来源:AbstractResource.java

示例9: createResource

import javax.faces.application.Resource; //导入依赖的package包/类
@Override
public Resource createResource(String resourceName, String libraryName) {
    final Resource resource = super.createResource(resourceName, libraryName);

    // here a check of library name could be necessary, etc.
    if (libraryName.startsWith("butterfaces")) {
        return new ButterFacesResource(resource);
    }

    return resource;
}
 
开发者ID:ButterFaces,项目名称:ButterFaces,代码行数:12,代码来源:ButterFacesResourceHandler.java

示例10: encodeJS

import javax.faces.application.Resource; //导入依赖的package包/类
protected void encodeJS(FacesContext context, String library, String resource) throws IOException {
	ResponseWriter writer = context.getResponseWriter();

	Resource jsResource = context.getApplication().getResourceHandler().createResource(resource, library);

	if (jsResource == null)
		throw new FacesException("Error loading js, cannot find \"" + resource + "\" resource of \"" + library + "\" library");

	else {
		writer.startElement("script", null);
		writer.writeAttribute("src", jsResource.getRequestPath(), null);
		writer.endElement("script");
	}
}
 
开发者ID:edvin,项目名称:tornadofaces,代码行数:15,代码来源:HeadRenderer.java

示例11: createResource

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Basic resource creation method. First tries to find the resource in the wrapped
 * resource handler and if not found there, locates the resource in one of the
 * {@link BundleResource} services that are tracked.
 */
@Override
public Resource createResource(String name, String lib, String type) {
    Resource resource = null;
    // Get the resource from the other bundles.
    BundleResource thisResource = getResource(lib, name);
    if (thisResource != null) {
        ServletContext context =
                (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
        // Find the faces registration.
        Optional<? extends ServletRegistration> registration =
                context.getServletRegistrations().values().stream().
                filter((sr) -> "javax.faces.webapp.FacesServlet".equals(sr.getClassName())).findFirst();
        // Check the mapping.
        String first = registration.get().getMappings().iterator().next();
        String p = null;
        // This is all according to the Faces specification.
        if (first.startsWith("*")) {
            // Extension mapping.
            p = context.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER + "/{}" + first.substring(1);
        }
        else if (first.endsWith("*")){
            // Must be prefix mapping.
            p = context.getContextPath() + first.substring(0, first.length() - 2) +
                    ResourceHandler.RESOURCE_IDENTIFIER + "/{}";
        }
        else {
            throw new RuntimeException("(bugcheck): cannot determine path for Faces servlet");
        }
        // Wrap it into a Resource object.
        resource = new OurResource(thisResource.getURL(), p);
        resource.setLibraryName(lib);
        resource.setResourceName(name);
    }
    else {
        resource = getWrapped().createResource(name, lib, type);
    }
    return resource;
}
 
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:44,代码来源:BundleResourceHandler.java

示例12: getURLImagemResource

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * Retorna a url da imagem localizada na pasta imagem dentro de resources
 * @param nomeDaImagem
 * @return
 */
private static String getURLImagemResource(String nomeDaImagem){
	ResourceHandler rs = LiferayFacesContext.getInstance().getApplication()
			.getResourceHandler();
	Resource resource = rs.createResource(nomeDaImagem, "images");
	return resource.getRequestPath();
}
 
开发者ID:camaradosdeputadosoficial,项目名称:edemocracia,代码行数:12,代码来源:BibliotecaImagensUtil.java

示例13: createResource

import javax.faces.application.Resource; //导入依赖的package包/类
@Override
public Resource createResource(final String resourceName, final String libraryName) {
    final Resource resource = super.createResource(resourceName, libraryName);

    if (resource == null) {
        return null;
    }
    return new BsfResWrapper(resource);
    
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:11,代码来源:UnmappedResourceHandler.java

示例14: Datepicker

import javax.faces.application.Resource; //导入依赖的package包/类
public Datepicker() {
	setRendererType(null); // this component renders itself

	AddResourcesListener.addThemedCSSResource("core.css");
	AddResourcesListener.addExtCSSResource("jq.ui.core.css");
	AddResourcesListener.addExtCSSResource("jq.ui.theme.css");
	AddResourcesListener.addExtCSSResource("jq.ui.datepicker.css");

	AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "jq/ui/core.js");
	AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "jq/ui/datepicker.js");
	FacesContext context = FacesContext.getCurrentInstance();
	Application app = context.getApplication();
	ResourceHandler rh = app.getResourceHandler();
	Resource rdp;
	Iterator<Locale> preferredLanguages = context.getExternalContext().getRequestLocales();
	while (preferredLanguages.hasNext()) {
		String language = preferredLanguages.next().getLanguage();
		if ("en".equals(language)) {
			break;
		}
		final String jsl = "jq/ui/i18n/datepicker-" + language + ".js";
		rdp = rh.createResource(jsl, C.BSF_LIBRARY);
		if (rdp != null) { // rdp is null if the language .js is not present
							// in jar
			AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, jsl);
			break;
		}

	}
	Tooltip.addResourceFiles();
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:32,代码来源:Datepicker.java

示例15: getImageSource

import javax.faces.application.Resource; //导入依赖的package包/类
/**
 * <p>
 * Determine the path value of an image value.
 * </p>
 *
 * @param context
 *            the {@link FacesContext} for the current request.
 * @param component
 *            the component to obtain the image information from
 * @return the encoded path to the image source
 */
public static String getImageSource(FacesContext context, UIComponent component) {
	Image image = (Image) component;
	ResourceHandler handler = context.getApplication().getResourceHandler();
	String resourceName = image.getName();
	String value = image.getValue();
	if (value != null && value.length() > 0) {
		if (resourceName != null && image.getLibrary() != null) {
			if (FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Development)) {
				LOGGER.warning(
						"Please use either the 'value' attribute of b:image, or the 'name' and 'library' attribute pair. If all three attributes are provided, BootsFaces uses the 'value' attributes, ignoring both 'name' and 'library'.");
			}
		}
		if (handler.isResourceURL(value)) {
			return value;
		} else {
			value = context.getApplication().getViewHandler().getResourceURL(context, value);
			return (context.getExternalContext().encodeResourceURL(value));
		}
	}

	String library = image.getLibrary();
	Resource res = handler.createResource(resourceName, library);
	if (res == null) {
		if (context.isProjectStage(ProjectStage.Development)) {
			String msg = "Unable to find resource " + resourceName;
			FacesMessages.error(component.getClientId(context), msg, msg);
		}
		return "RES_NOT_FOUND";
	} else {
		return (context.getExternalContext().encodeResourceURL(res.getRequestPath()));
	}
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:44,代码来源:ImageRenderer.java


注:本文中的javax.faces.application.Resource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。