Package org.apache.tapestry5.services.javascript

Examples of org.apache.tapestry5.services.javascript.JavaScriptStack


            StreamableResource uncompressed = assembleJavascriptResourceForStack(locale, stackName, false);

            return new CompressedStreamableResource(uncompressed, checksumGenerator);
        }

        JavaScriptStack stack = stackSource.getStack(stackName);

        return assembleStreamableForStack(locale.toString(), stackName, stack.getJavaScriptLibraries(), stack.getModules());
    }
View Full Code Here


        this.combineScripts = combineScripts;
    }

    public List<String> constructPathsForJavaScriptStack(String stackName)
    {
        JavaScriptStack stack = javascriptStackSource.getStack(stackName);

        List<Asset> assets = stack.getJavaScriptLibraries();

        // When combine scripts is true, we want to build the virtual aggregated JavaScript ... but only
        // if there is more than one library asset, or any modules.
        if (combineScripts)
        {
            boolean needsVirtual = (assets.size() > 1) || (!stack.getModules().isEmpty());

            if (needsVirtual)
            {
                return combinedStackURL(stackName);
            }
View Full Code Here

        this.configuration = configuration;
    }

    public JavaScriptStack getStack(String name)
    {
        JavaScriptStack stack = findStack(name);

        if (stack == null)
        {
            throw new UnknownValueException(String.format("No JavaScriptStack with name '%s'.", name),
                    new AvailableValues("Configured JavaScript stacks", configuration));
View Full Code Here

    private void addAssetsFromStack(String stackName)
    {
        if (addedStacks.containsKey(stackName))
            return;

        JavaScriptStack stack = javascriptStackSource.getStack(stackName);

        for (String dependentStackname : stack.getStacks())
        {
            addAssetsFromStack(dependentStackname);
        }

        stackLibraries.addAll(stackPathConstructor.constructPathsForJavaScriptStack(stackName));

        stylesheetLinks.addAll(stack.getStylesheets());

        String initialization = stack.getInitialization();

        if (initialization != null)
            linker.addScript(InitializationPriority.IMMEDIATE, initialization);

        addedStacks.put(stackName, true);
View Full Code Here

    }

    private void trainForEmptyCoreStack(DocumentLinker linker, JavaScriptStackSource stackSource,
            JavaScriptStackPathConstructor pathConstructor)
    {
        JavaScriptStack stack = mockJavaScriptStack();

        expect(stackSource.getStack(InternalConstants.CORE_STACK_NAME)).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack(InternalConstants.CORE_STACK_NAME)).andReturn(
                Collections.<String> emptyList());
        expect(stack.getStylesheets()).andReturn(Collections.<StylesheetLink> emptyList());

        expect(stack.getInitialization()).andReturn(null);

        expect(stack.getStacks()).andReturn(Collections.<String> emptyList());
    }
View Full Code Here

    }

    private void trainForCoreStack(DocumentLinker linker, JavaScriptStackSource stackSource,
            JavaScriptStackPathConstructor pathConstructor)
    {
        JavaScriptStack stack = mockJavaScriptStack();

        StylesheetLink stylesheetLink = new StylesheetLink("style.css");

        expect(stackSource.getStack(InternalConstants.CORE_STACK_NAME)).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack(InternalConstants.CORE_STACK_NAME)).andReturn(
                CollectionFactory.newList("stack1.js", "stack2.js"));
        expect(stack.getStylesheets()).andReturn(CollectionFactory.newList(stylesheetLink));

        expect(stack.getInitialization()).andReturn("stackInit();");

        expect(stack.getStacks()).andReturn(Collections.<String> emptyList());

        linker.addScriptLink("stack1.js");
        linker.addScriptLink("stack2.js");
        linker.addStylesheetLink(stylesheetLink);
    }
View Full Code Here

        trainForEmptyCoreStack(linker, stackSource, pathConstructor);

        Asset library1 = mockAsset("mylib1.js");
        Asset library2 = mockAsset("mylib2.js");

        JavaScriptStack mystack = mockJavaScriptStack();

        expect(stackSource.getStackNames()).andReturn(Arrays.asList("mystack"));
        expect(stackSource.getStack("mystack")).andReturn(mystack).atLeastOnce();

        expect(mystack.getStacks()).andReturn(Collections.<String> emptyList());
        expect(mystack.getJavaScriptLibraries()).andReturn(Arrays.asList(library1, library2));

        expect(pathConstructor.constructPathsForJavaScriptStack("mystack")).andReturn(
                Arrays.asList("stacks/mystack.js"));
        expect(mystack.getStylesheets()).andReturn(Collections.<StylesheetLink> emptyList());

        expect(mystack.getInitialization()).andReturn(null);

        linker.addScriptLink("stacks/mystack.js");

        replay();
View Full Code Here

        JavaScriptStackSource stackSource = mockJavaScriptStackSource();
        JavaScriptStackPathConstructor pathConstructor = mockJavaScriptStackPathConstructor();

        trainForCoreStack(linker, stackSource, pathConstructor);

        JavaScriptStack stack = mockJavaScriptStack();

        StylesheetLink stylesheetLink = new StylesheetLink("stack.css");

        expect(stackSource.getStack("custom")).andReturn(stack);
        expect(pathConstructor.constructPathsForJavaScriptStack("custom")).andReturn(
                CollectionFactory.newList("stack.js"));
        expect(stack.getStylesheets()).andReturn(CollectionFactory.newList(stylesheetLink));

        expect(stack.getInitialization()).andReturn("customInit();");

        List<String> stacks = Collections.emptyList();
        expect(stack.getStacks()).andReturn(stacks);

        linker.addScriptLink("stack.js");
        linker.addStylesheetLink(stylesheetLink);

        linker.addScript(InitializationPriority.IMMEDIATE, "stackInit();");
View Full Code Here

        JavaScriptStackSource stackSource = mockJavaScriptStackSource();
        JavaScriptStackPathConstructor pathConstructor = mockJavaScriptStackPathConstructor();

        trainForCoreStack(linker, stackSource, pathConstructor);

        JavaScriptStack child = mockJavaScriptStack();
        JavaScriptStack parent = mockJavaScriptStack();

        StylesheetLink parentStylesheetLink = new StylesheetLink("parent.css");

        StylesheetLink childStylesheetLink = new StylesheetLink("child.css");

        expect(stackSource.getStack("child")).andReturn(child);

        expect(child.getStacks()).andReturn(Arrays.asList("parent"));

        expect(stackSource.getStack("parent")).andReturn(parent);

        expect(pathConstructor.constructPathsForJavaScriptStack("parent")).andReturn(Arrays.asList("parent.js"));
        expect(parent.getStylesheets()).andReturn(Arrays.asList(parentStylesheetLink));

        expect(parent.getInitialization()).andReturn("parentInit();");

        expect(pathConstructor.constructPathsForJavaScriptStack("child")).andReturn(Arrays.asList("child.js"));
        expect(child.getStylesheets()).andReturn(Arrays.asList(childStylesheetLink));

        expect(child.getInitialization()).andReturn("childInit();");

        expect(parent.getStacks()).andReturn(Collections.<String> emptyList());

        linker.addScriptLink("parent.js");
        linker.addScriptLink("child.js");

        linker.addStylesheetLink(parentStylesheetLink);
View Full Code Here

        MarkupWriter writer = factory.newPartialMarkupWriter(contentType);

        generateResponseMarkup(writer, matchesHolder.get());

        return new TextStreamResponse(contentType.toString(), writer.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.javascript.JavaScriptStack

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.