本文整理了Java中javax.faces.application.Resource.getRequestPath
方法的一些代码示例,展示了Resource.getRequestPath
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getRequestPath
方法的具体详情如下:
包路径:javax.faces.application.Resource
类名称:Resource
方法名:getRequestPath
[英]Return a path to this resource such that, when the browser resolves it against the base URI for the view that includes the resource, and issues a GET request to the resultant fully qualified URL, the bytes of the resource are returned in response.
The default implementation must implement the following algorithm. For discussion, the return result from this method will be called result.
FacesServlet
is prefix (path) mapped, extension mapped, or exact mapped (as defined by Servlet.12.2.) and the value of the mapping (including the leading '.' in the case of extension mapping). For discussion, this will be facesServletMapping.result = *contextRoot* + ResourceHandler#RESOURCE_IDENTIFIER + #getResourceName
If exact mapped, and the FacesServlet is not mapped to the exact URL pattern ResourceHandler#RESOURCE_IDENTIFIER + #getResourceNamedo the following:
Retrieve the existing mappings of the FacesServlet, e.g. using ServletRegistration#getMappings(), and from those pick any prefix mapping or extension mapping. If no such mapping is found, throw an IllegalStateException. If such mapping is found remove the *
character from that mapping, take that as the new facesServletMapping and continue with evaluating this mapping as specified below for if prefix mapped and for if extension mapped
If prefix mapped, result must be
result = *contextRoot* + '/' + *facesServletMapping* + ResourceHandler#RESOURCE_IDENTIFIER + '/' + #getResourceName
If extension mapped, result must be
result = *contextRoot* + ResourceHandler#RESOURCE_IDENTIFIER + #getResourceName + *facesServletMapping*
null
, resourceMetaData
must include "ln=" + the return from #getLibraryNameIf there is a localePrefix
for this application, as defined in ResourceHandler#LOCALE_PREFIX, resourceMetaData
must include "loc=" + the localePrefix
.
If this resource is contained in a resource library contract, resourceMetaData
must include "con=" + the name of the resource library contract.
Append "?" + resourceMetaData to result.
FacesServlet
是前缀(路径)映射、扩展映射还是精确映射(如Servlet.12.2所定义)以及映射的值(对于扩展映射,包括前导“.”)。为了便于讨论,这将是facesServletMapping*。result = *contextRoot* + ResourceHandler#RESOURCE_IDENTIFIER + #getResourceName
*
字符,将其作为新的facesServletMapping,并继续按照下面为If prefix mapped和If extension mapped指定的方法计算该映射*result = *contextRoot* + '/' + *facesServletMapping* + ResourceHandler#RESOURCE_IDENTIFIER + '/' + #getResourceName
result = *contextRoot* + ResourceHandler#RESOURCE_IDENTIFIER + #getResourceName + *facesServletMapping*
null
,则resourceMetaData
必须包含“ln=”+从#getLibraryName返回的值localePrefix
,则resourceMetaData
必须包含“loc=”+thelocalePrefix
。resourceMetaData
必须包含“con=”+资源库合同的名称。代码示例来源:origin: primefaces/primefaces
public static String getResourceRequestPath(FacesContext context, String resourceName) {
Resource resource = context.getApplication().getResourceHandler().createResource(resourceName, "primefaces");
return resource.getRequestPath();
}
代码示例来源:origin: primefaces/primefaces
String resourcePath = resource.getRequestPath();
代码示例来源:origin: primefaces/primefaces
Resource resource = context.getApplication().getResourceHandler().createResource(
"dynamiccontent.properties", "primefaces", streamedContent.getContentType());
String resourcePath = resource.getRequestPath();
代码示例来源:origin: primefaces/primefaces
protected void encodeValidationResources(FacesContext context, boolean beanValidationEnabled) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Resource resource = context.getApplication().getResourceHandler().createResource("validation/validation.js", "primefaces");
if (resource != null) {
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", resource.getRequestPath(), null);
writer.endElement("script");
}
if (beanValidationEnabled) {
resource = context.getApplication().getResourceHandler().createResource("validation/beanvalidation.js", "primefaces");
if (resource != null) {
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", resource.getRequestPath(), null);
writer.endElement("script");
}
}
}
}
代码示例来源:origin: primefaces/primefaces
protected String getImageSrc(FacesContext context, GraphicImage image) throws Exception {
String name = image.getName();
if (name != null) {
String libName = image.getLibrary();
ResourceHandler handler = context.getApplication().getResourceHandler();
Resource res = handler.createResource(name, libName);
if (res == null) {
return "RES_NOT_FOUND";
}
else {
String requestPath = res.getRequestPath();
return context.getExternalContext().encodeResourceURL(requestPath);
}
}
else {
return DynamicContentSrcBuilder.build(context, image.getValue(), image, image.isCache(), DynamicContentType.STREAMED_CONTENT, image.isStream());
}
}
}
代码示例来源:origin: primefaces/primefaces
protected void encodeCSS(FacesContext context, String library, String resource) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Resource cssResource = context.getApplication().getResourceHandler().createResource(resource, library);
if (cssResource == null) {
throw new FacesException("Error loading css, cannot find \"" + resource + "\" resource of \"" + library + "\" library");
}
else {
writer.startElement("link", null);
writer.writeAttribute("type", "text/css", null);
writer.writeAttribute("rel", "stylesheet", null);
writer.writeAttribute("href", cssResource.getRequestPath(), null);
writer.endElement("link");
}
}
代码示例来源:origin: primefaces/primefaces
private void encodeScript(FacesContext context, Editor editor) throws IOException {
String clientId = editor.getClientId(context);
WidgetBuilder wb = getWidgetBuilder(context);
wb.init("Editor", editor.resolveWidgetVar(), clientId)
.attr("disabled", editor.isDisabled(), false)
.attr("invalid", editor.isValid(), true)
.attr("controls", editor.getControls(), null)
.attr("width", editor.getWidth(), Integer.MIN_VALUE)
.attr("height", editor.getHeight(), Integer.MIN_VALUE)
.attr("maxlength", editor.getMaxlength(), Integer.MAX_VALUE)
.callback("change", "function(e)", editor.getOnchange());
if (AgentUtils.isIE(context)) {
Resource resource = context.getApplication().getResourceHandler().createResource("editor/editor-ie.css", "primefaces");
wb.attr("docCSSFile", resource.getRequestPath());
}
if (editor.getMaxlength() != Integer.MAX_VALUE) {
LOGGER.info("Maxlength option is deprecated and will be removed in a future version.");
}
wb.finish();
}
代码示例来源:origin: com.sun.faces/jsf-api
/**
* <p class="changed_added_2_0">Call through to {@link
* #getRequestPath} and return the result.</p>
*
* @return Call through to {@link #getRequestPath} and return the
* result.
*/
public String toString() {
return getRequestPath();
}
代码示例来源:origin: javax/javaee-web-api
/**
* <p class="changed_added_2_0">Call through to {@link
* #getRequestPath} and return the result.</p>
*
* @return Call through to {@link #getRequestPath} and return the
* result.
*/
@Override
public String toString() {
return getRequestPath();
}
代码示例来源:origin: org.apache.myfaces.core/myfaces-api
@Override
public String toString()
{
return getRequestPath();
}
代码示例来源:origin: org.glassfish/javax.faces
/**
* <p class="changed_added_2_0">
* Call through to {@link #getRequestPath} and return the result.
* </p>
*
* @return Call through to {@link #getRequestPath} and return the result.
*/
@Override
public String toString() {
return getRequestPath();
}
代码示例来源:origin: javax/javaee-web-api
/**
* <p class="changed_added_2_0">The default behavior of this method
* is to call {@link Resource#getRequestPath} on the wrapped {@link
* ResourceHandler} object.</p>
*/
@Override
public String getRequestPath() {
return getWrapped().getRequestPath();
}
代码示例来源:origin: org.apache.myfaces.core/myfaces-api
@Override
public String getRequestPath()
{
return getWrapped().getRequestPath();
}
代码示例来源:origin: com.sun.faces/jsf-api
/**
* <p class="changed_added_2_0">The default behavior of this method
* is to call {@link Resource#getRequestPath} on the wrapped {@link
* ResourceHandler} object.</p>
*/
@Override
public String getRequestPath() {
return getWrapped().getRequestPath();
}
代码示例来源:origin: javax.faces/javax.faces-api
/**
* <p class="changed_added_2_0">The default behavior of this method
* is to call {@link Resource#getRequestPath} on the wrapped {@link
* ResourceHandler} object.</p>
*/
@Override
public String getRequestPath() {
return getWrapped().getRequestPath();
}
代码示例来源:origin: org.richfaces.ui/richfaces-components-ui
public static String getResourcePath(FacesContext context, String library, String resourceName) {
String path = null;
if (resourceName != null) {
ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
Resource resource = (library != null) ? resourceHandler.createResource(resourceName, library) : resourceHandler
.createResource(resourceName);
if (resource != null) {
path = resource.getRequestPath();
}
}
return path;
}
代码示例来源:origin: org.omnifaces/omnifaces
/**
* If the given resource is not <code>null</code>, then decorate it as an unmapped resource.
*/
@Override
public Resource decorateResource(Resource resource) {
if (resource == null) {
return resource;
}
String path = resource.getRequestPath();
return isResourceRequest(path) ? new RemappedResource(resource, unmapRequestPath(path)) : resource;
}
代码示例来源:origin: omnifaces/omnifaces
/**
* If the given resource is not <code>null</code>, then decorate it as an unmapped resource.
*/
@Override
public Resource decorateResource(Resource resource) {
if (resource == null) {
return resource;
}
String path = resource.getRequestPath();
return isResourceRequest(path) ? new RemappedResource(resource, unmapRequestPath(path)) : resource;
}
代码示例来源:origin: org.primefaces/primefaces
private void renderJS(FacesContext context, String name, String library) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Resource resource = context.getApplication().getResourceHandler().createResource(name, library);
if (resource != null) {
writer.startElement("script", null);
writer.writeAttribute("type", "text/javascript", null);
writer.writeAttribute("src", resource.getRequestPath(), null);
writer.endElement("script");
}
}
代码示例来源:origin: org.primefaces/primefaces
private void renderCSS(FacesContext context, String name, String library) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Resource resource = context.getApplication().getResourceHandler().createResource(name, library);
if (resource != null) {
writer.startElement("link", null);
writer.writeAttribute("type", "text/css", null);
writer.writeAttribute("rel", "stylesheet", null);
writer.writeAttribute("href", resource.getRequestPath(), null);
writer.endElement("link");
}
}
}
内容来源于网络,如有侵权,请联系作者删除!