use of javax.faces.application.Resource in project liferay-faces-alloy by liferay.
the class MediaRenderer method encodeFlashPlayer.
protected void encodeFlashPlayer(FacesContext facesContext, ResponseWriter responseWriter, Media media, String mediaResourceURL) throws IOException {
BrowserSniffer browserSniffer = BrowserSnifferFactory.getBrowserSnifferInstance(facesContext.getExternalContext());
boolean browserIE = browserSniffer.isIe();
responseWriter.startElement("object", null);
encodeMediaSize(responseWriter, media);
Application application = facesContext.getApplication();
ResourceHandler resourceHandler = application.getResourceHandler();
Object flashPlayer = media.getFlashPlayer();
String flashPlayerURL;
// If the developer has specified a Flash player, then
if (flashPlayer != null) {
flashPlayerURL = getEncodedResourceURL(facesContext, resourceHandler, application, flashPlayer);
} else // Otherwise, get the default Alloy Flash player.
{
Resource defaultFlashPlayerResource = resourceHandler.createResource(getDefaultFlashPlayerName(), "liferay-faces-alloy");
String defaultFlashPlayerRequestPath = defaultFlashPlayerResource.getRequestPath();
ExternalContext externalContext = facesContext.getExternalContext();
flashPlayerURL = externalContext.encodeResourceURL(defaultFlashPlayerRequestPath);
}
if (browserIE) {
responseWriter.writeAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", null);
String flashPlayerVersion = media.getFlashPlayerVersion();
String codebaseURL = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=".concat(flashPlayerVersion);
responseWriter.writeAttribute("codebase", codebaseURL, null);
responseWriter.startElement("param", null);
responseWriter.writeAttribute("name", "movie", null);
responseWriter.writeAttribute("value", flashPlayerURL, null);
responseWriter.endElement("param");
} else {
responseWriter.writeAttribute("data", flashPlayerURL, null);
responseWriter.writeAttribute("type", "application/x-shockwave-flash", null);
}
encodeFlashPlayerChildren(facesContext, responseWriter, media, mediaResourceURL, resourceHandler, application, (flashPlayer == null));
responseWriter.endElement("object");
}
use of javax.faces.application.Resource in project liferay-faces-bridge-ext by liferay.
the class JSResourceWithDisabledAMDLoaderImpl method initFilteredResourceCache.
/**
* This method initializes the filtered resource cache for JSResourceWithDisabledAMDLoaderImpl. The initialization
* cannot be performed in the constructor of {@link
* com.liferay.faces.bridge.ext.application.internal.ResourceHandlerLiferayImpl} since that class is created before
* the {@link CacheFactory} has been created. This method is called in {@link
* com.liferay.faces.bridge.ext.event.internal.PostConstructApplicationConfigEventListener#processEvent(javax.faces.event.SystemEvent)
* } to ensure that the CacheFactory has been created.
*
* @param initFacesContext
*/
public static void initFilteredResourceCache(FacesContext initFacesContext) {
if (!initFacesContext.isProjectStage(ProjectStage.Development)) {
ExternalContext externalContext = initFacesContext.getExternalContext();
Cache<String, Resource> filteredResourceCache;
int initialCacheCapacity = LiferayPortletConfigParam.DisabledAMDLoaderResourcesInitialCacheCapacity.getIntegerValue(externalContext);
int maxCacheCapacity = LiferayPortletConfigParam.DisabledAMDLoaderResourcesMaxCacheCapacity.getIntegerValue(externalContext);
if (maxCacheCapacity > -1) {
filteredResourceCache = CacheFactory.getConcurrentLRUCacheInstance(externalContext, initialCacheCapacity, maxCacheCapacity);
} else {
filteredResourceCache = CacheFactory.getConcurrentCacheInstance(externalContext, initialCacheCapacity);
}
Map<String, Object> applicationMap = externalContext.getApplicationMap();
applicationMap.put(JSResourceWithDisabledAMDLoaderImpl.class.getName(), filteredResourceCache);
}
}
Aggregations