Package org.apache.tapestry

Examples of org.apache.tapestry.Asset


        Element head = document.find("html/head");

        if (head == null)
            return;

        Asset asset = _assetSource.getClasspathAsset(
                "org/apache/tapestry/default.css",
                _threadLocale.getLocale());

        head.elementAt(0, "link", "rel", "stylesheet", "type", "text/css", "href", asset
                .toClientURL());
    }
View Full Code Here


    {
        Document d = new Document();
        ThreadLocale tl = newThreadLocale();
        AssetSource source = newAssetSource();
        Environment env = newEnvironment();
        Asset asset = newAsset();
        Locale l = Locale.FRENCH;

        d.newRootElement("html").element("head");

        train_peek(env, Document.class, d);
View Full Code Here

    @Test
    public void relative_asset()
    {
        AssetFactory factory = newAssetFactory();
        Asset asset = newAsset();

        Resource expectedResource = _baseResource.forFile("SimpleComponent_en_GB.properties");

        train_getRootResource(factory, _rootResource);
View Full Code Here

    @Test
    public void get_classpath_asset()
    {
        AssetFactory factory = newAssetFactory();
        Asset asset = newAsset();

        Resource expectedResource = _baseResource.forFile("SimpleComponent_en_GB.properties");

        train_getRootResource(factory, _rootResource);
View Full Code Here

    @Test
    public void absolute_asset_with_known_prefix()
    {
        AssetFactory factory = newAssetFactory();
        Asset asset = newAsset();

        Resource expectedResource = _rootResource
                .forFile("org/apache/tapestry/internal/services/SimpleComponent_en_GB.properties");

        train_getRootResource(factory, _rootResource);
View Full Code Here

    public <T> T provide(String expression, Class<T> objectType, ServiceLocator locator)
    {
        if (!objectType.isAssignableFrom(Asset.class))
            throw new RuntimeException(ServicesMessages.assetNotCompatible(expression, objectType));

        Asset asset = _source.findAsset(_classpathRootResource, expression, _threadLocale
                .getLocale());

        return objectType.cast(asset);
    }
View Full Code Here

    {
        // TODO: Assets will eventually have a kind of symbolic link used
        // to shorten the path. Some assets may need to have a checksum embedded
        // in the path as well.

        return new Asset()
        {
            public Resource getResource()
            {
                return resource;
            }
View Full Code Here

        return getAssetForResource(localized);
    }

    private Asset getAssetForResource(Resource resource)
    {
        Asset result = _cache.get(resource);

        if (result == null)
        {
            result = createAssetFromResource(resource);
            _cache.put(resource, result);
View Full Code Here

    public Asset createAsset(final Resource resource)
    {
        final String contextPath = _request.getContextPath() + "/" + resource.getPath();

        return new Asset()
        {
            public Resource getResource()
            {
                return resource;
            }
View Full Code Here

        replay();

        ClasspathAssetFactory factory = new ClasspathAssetFactory(cache, aliasManager);

        Asset asset = factory.createAsset(r);

        assertEquals(asset.toClientURL(), expectedClientURL);

        // Now, to check the cache:

        assertEquals(asset.toClientURL(), expectedClientURL);

        verify();

        // Now, to test cache clearing:
        train_requiresDigest(cache, r, false);

        train_toClientURL(aliasManager, "foo/Bar.txt", expectedClientURL);

        replay();

        factory.objectWasInvalidated();

        assertEquals(asset.toClientURL(), expectedClientURL);

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.Asset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.