/** * Converts an {@link IAsset}binding into a usable URL. Returns null if the * binding does not exist or the binding's value is null. * * @param asset * The asset to generate a url for. * @return The url to the asset resource, or null if it couldn't be generated. */ protected String getAssetURL(IAsset asset) { if (asset == null) return null; return asset.buildURL(); }
public Resource getResourceLocation() { return asset.getResourceLocation(); }
public Location getLocation() { return asset.getLocation(); } }
public InputStream getResourceAsStream() { return asset.getResourceAsStream(); }
/** * Converts an {@link IAsset}binding into a usable URL. Returns null if the * binding does not exist or the binding's value is null. * * @param asset * The asset to generate a url for. * @return The url to the asset resource, or null if it couldn't be generated. */ protected String getAssetURL(IAsset asset) { if (asset == null) return null; return asset.buildURL(); }
private Resource findSpecificationResource(Resource libraryResource, String path, Location location) { // TODO: This is where we'll play with assets and asset prefixes IAsset childAsset = _assetSource.findAsset(libraryResource, path, null, location); Resource childResource = childAsset.getResourceLocation(); return childResource; }
/** * Appends a script tag to include the given asset. * @param str * @param cycle * @param asset */ protected void appendAssetAsJavascript(StringBuffer str, IRequestCycle cycle, IAsset asset) { final String url = asset.buildURL(); str.append("<script type=\"text/javascript\" src=\"").append(url) .append("\"></script>").append(SYSTEM_NEWLINE); }
private Resource findSpecificationResource(Resource libraryResource, String path, Location location) { // TODO: This is where we'll play with assets and asset prefixes IAsset childAsset = _assetSource.findAsset(libraryResource, path, null, location); Resource childResource = childAsset.getResourceLocation(); return childResource; }
/** * Extracts its asset URL, sets it up for preloading, and assigns the preload reference as a * script symbol. */ private void setImage(PageRenderSupport pageRenderSupport, IRequestCycle cycle, String symbolName, IAsset asset) { String url = asset.buildURL(); String reference = pageRenderSupport.getPreloadedImageReference(this, url); _symbols.put(symbolName, reference); }
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) { if (!cycle.isRewinding() && !isDisabled()) { cycle.getResponseBuilder().addExternalScript(this, getScriptAsset().getResourceLocation()); } }
public String getPreloadedImageReference(IComponent target, IAsset source) { return getPreloadedImageReference(target, source.buildURL()); }
if (templateAsset != null && templateAsset.getResourceLocation() != null && templateAsset.getResourceLocation().getResourceURL() != null) return readTemplateFromAsset(cycle, component, templateAsset.getResourceLocation());
public String getPreloadedImageReference(IComponent target, IAsset source) { return getPreloadedImageReference(target, source.buildURL()); }
if (templateAsset != null && templateAsset.getResourceLocation() != null && templateAsset.getResourceLocation().getResourceURL() != null) return readTemplateFromAsset(cycle, component, templateAsset.getResourceLocation());
public String buildURL() { return absoluteURLBuilder.constructURL(asset.buildURL()); }
return _contextAssetFactory.createAsset(_webInfAppLocation, component.getSpecification(), templateName, locale, component.getLocation()).getResourceLocation(); } else if (_contextAssetFactory.assetExists(component.getSpecification(), _webInfLocation, templateName, locale)) return _contextAssetFactory.createAsset(_webInfLocation, component.getSpecification(), templateName, locale, component.getLocation()).getResourceLocation(); return _classpathAssetFactory.createAsset(base, component.getSpecification(), resourceName, locale, component.getLocation()).getResourceLocation(); return _contextAssetFactory.createAsset(_webInfAppLocation, component.getSpecification(), templatePath, locale, component.getLocation()).getResourceLocation(); } else if (_contextAssetFactory.assetExists(component.getSpecification(), _webInfLocation, templatePath, locale)) return _contextAssetFactory.createAsset(_webInfLocation, component.getSpecification(), templatePath, locale, component.getLocation()).getResourceLocation();
private void writeExternalScripts(IMarkupWriter writer, IRequestCycle cycle) { int count = Tapestry.size(_externalScripts); for (int i = 0; i < count; i++) { Resource scriptLocation = (Resource) _externalScripts.get(i); IAsset asset = _assetFactory.createAsset(scriptLocation, null); String url = asset.buildURL(); // Note: important to use begin(), not beginEmpty(), because browser don't // interpret <script .../> properly. _builder.writeExternalScript(writer, url, cycle); } }
return _contextAssetFactory.createAsset(_webInfAppLocation, component.getSpecification(), templateName, locale, component.getLocation()).getResourceLocation(); } else if (_contextAssetFactory.assetExists(component.getSpecification(), _webInfLocation, templateName, locale)) return _contextAssetFactory.createAsset(_webInfLocation, component.getSpecification(), templateName, locale, component.getLocation()).getResourceLocation(); return _classpathAssetFactory.createAsset(base, component.getSpecification(), resourceName, locale, component.getLocation()).getResourceLocation(); return _contextAssetFactory.createAsset(_webInfAppLocation, component.getSpecification(), templatePath, locale, component.getLocation()).getResourceLocation(); } else if (_contextAssetFactory.assetExists(component.getSpecification(), _webInfLocation, templatePath, locale)) return _contextAssetFactory.createAsset(_webInfLocation, component.getSpecification(), templatePath, locale, component.getLocation()).getResourceLocation();
private void writeExternalScripts(IMarkupWriter writer, IRequestCycle cycle) { int count = Tapestry.size(_externalScripts); for (int i = 0; i < count; i++) { Resource scriptLocation = (Resource) _externalScripts.get(i); IAsset asset = _assetFactory.createAsset(scriptLocation, null); String url = asset.buildURL(); // Note: important to use begin(), not beginEmpty(), because browser don't // interpret <script .../> properly. _builder.writeExternalScript(writer, url, cycle); } }
return source.getScript(scriptAsset.getResourceLocation());