javax.faces.application.ResourceHandler Java Examples
The following examples show how to use
javax.faces.application.ResourceHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InternalIE8CompatiblityLinks.java From BootsFaces-OSP with Apache License 2.0 | 6 votes |
@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]-->"); }
Example #2
Source File: CacheControlFilter.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; if (!request.getRequestURI().startsWith(request.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc) response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies. } chain.doFilter(req, res); }
Example #3
Source File: ApplicationErrorFilter.java From sailfish-core with Apache License 2.0 | 5 votes |
@Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; request.getSession(); if(request.getRequestURI().startsWith(request.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { chain.doFilter(request, response); return; } if(SFWebApplication.getInstance().isFatalError()) { if(request.getServletPath().endsWith(FATAL_ERROR_PAGE)) { chain.doFilter(request, response); return; } if(request.getServletPath().endsWith(INTERNAL_ERROR_PAGE)) { response.sendRedirect(FATAL_ERROR_PAGE); return; } if(isPage(request.getServletPath())) { response.sendRedirect(ERROR_PAGES_FOLDER + "/" +FATAL_ERROR_PAGE); return; } } chain.doFilter(request, response); }
Example #4
Source File: Datepicker.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
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(); }
Example #5
Source File: ImageRenderer.java From BootsFaces-OSP with Apache License 2.0 | 5 votes |
/** * <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())); } }
Example #6
Source File: DeltaSpikeResourceHandler.java From deltaspike with Apache License 2.0 | 5 votes |
public DeltaSpikeResourceHandler(ResourceHandler resourceHandler) { super(); wrapped = resourceHandler; version = ClassUtils.getJarVersion(this.getClass()); activated = ClassDeactivationUtils.isActivated(this.getClass()); }
Example #7
Source File: ResourceHandlerWrapper.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
public ResourceHandlerWrapper(ResourceHandler wrapped) { super(wrapped); }
Example #8
Source File: JsfBeansAutoConfiguration.java From joinfaces with Apache License 2.0 | 4 votes |
@Bean("resource") @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS) @ConditionalOnMissingBean public ResourceHandler resourceHandler() { return FacesContext.getCurrentInstance().getApplication().getResourceHandler(); }
Example #9
Source File: UnmappedResourceHandler.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
public UnmappedResourceHandler(ResourceHandler wrapped) { this.wrapped = wrapped; }
Example #10
Source File: UnmappedResourceHandler.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
@Override public boolean isResourceRequest(FacesContext context) { return ResourceHandler.RESOURCE_IDENTIFIER.equals(context.getExternalContext().getRequestServletPath()); }
Example #11
Source File: UnmappedResourceHandler.java From BootsFaces-OSP with Apache License 2.0 | 4 votes |
@Override public ResourceHandler getWrapped() { return wrapped; }
Example #12
Source File: DeltaSpikeResourceHandler.java From deltaspike with Apache License 2.0 | 4 votes |
@Override public ResourceHandler getWrapped() { return wrapped; }