Package org.apache.flex.forks.velocity

Examples of org.apache.flex.forks.velocity.VelocityContext


     *         and rethrow as a <code>BuildException</code>
     */
    public Context initControlContext()
        throws Exception
    {
        return new VelocityContext();
    }
View Full Code Here


       
        strArray[0] = "array hello 1";
        strArray[1] = "array hello 2";
        strArray[2] = "array hello 3";
      
        VelocityContext context = new VelocityContext();
      
        try
        {
            assureResultsDirectoryExists(RESULT_DIR);
           
            /*
             *  get the template and the output
             */

            Template template = RuntimeSingleton.getTemplate(
                getFileName(null, "context_safety", TMPL_FILE_EXT));

            FileOutputStream fos1 =
                new FileOutputStream (
                    getFileName(RESULT_DIR, "context_safety1", RESULT_FILE_EXT));

            FileOutputStream fos2 =
                new FileOutputStream (
                    getFileName(RESULT_DIR, "context_safety2", RESULT_FILE_EXT));

            Writer writer1 = new BufferedWriter(new OutputStreamWriter(fos1));
            Writer writer2 = new BufferedWriter(new OutputStreamWriter(fos2));
           
            /*
             *  put the Vector into the context, and merge
             */

            context.put("vector", v)
            template.merge(context, writer1);
            writer1.flush();
            writer1.close();
           
            /*
             *  now put the string array into the context, and merge
             */

            context.put("vector", strArray)
            template.merge(context, writer2);
            writer2.flush();
            writer2.close();

            if (!isMatch(RESULT_DIR,COMPARE_DIR,"context_safety1",
View Full Code Here

     */
    public void runTest ()
    {
        String template = "$woogie.doException() boing!";

        VelocityContext vc = new VelocityContext();
       
        vc.put("woogie", this );

        StringWriter w = new StringWriter();

        try
        {
View Full Code Here

    {
        sawCacheDump = false;
                       
        try
        {
            VelocityContext vc = new VelocityContext();
            Object foo = null;

            /*
             *  first, we need a classloader to make our foo object
             */

            TestClassloader cl = new TestClassloader();
            Class fooclass = cl.loadClass("Foo");
            foo = fooclass.newInstance();

            /*
             *  put it into the context
             */
            vc.put("foo", foo);
       
            /*
             *  and render something that would use it
             *  that will get it into the introspector cache
             */
            StringWriter writer = new StringWriter();
            ve.evaluate( vc, writer, "test", "$foo.doIt()");

            /*
             *  Check to make sure ok.  note the obvious
             *  dependency on the Foo class...
             */
            
            if ( !writer.toString().equals( OUTPUT ))
            {
               fail("Output from doIt() incorrect");
            }
            
            /*
             * and do it again :)
             */
            cl = new TestClassloader();
            fooclass = cl.loadClass("Foo");
            foo = fooclass.newInstance();
           
            vc.put("foo", foo);
       
            writer = new StringWriter();
            ve.evaluate( vc, writer, "test", "$foo.doIt()");

            if ( !writer.toString().equals( OUTPUT ))
View Full Code Here

           
            /*
             *  put the Vector into the context, and merge both
             */

            VelocityContext context = new VelocityContext();

            template1.merge(context, writer1);
            writer1.flush();
            writer1.close();
           
View Full Code Here

           
            /*
             *  put the Vector into the context, and merge both
             */

            VelocityContext context = new VelocityContext();

            template1.merge(context, writer1);
            writer1.flush();
            writer1.close();
           
View Full Code Here

           
            /*
             *  put the Vector into the context, and merge both
             */

            VelocityContext context = new VelocityContext();

            template1.merge(context, writer1);
            writer1.flush();
            writer1.close();
           
View Full Code Here

        /*
         *  set up 3 chained contexts, and add our data
         *  throught the 3 of them.
         */

        context2 = new VelocityContext();
        context1 = new VelocityContext( context2 );
        context = new VelocityContext( context1 );

        context.put("provider", provider);
        context1.put("name", "jason");
        context2.put("providers", provider.getCustomers2());
        context.put("list", al);
View Full Code Here

                // Build the JDOM Document
                Document root = builder.build(inFile);

                // Shove things into the Context
                VelocityContext context = new VelocityContext();

                /*
                 *  get the property TEMPLATE_ENCODING
                 *  we know it's a string...
                 */
                String encoding = (String) ve.getProperty( RuntimeConstants.OUTPUT_ENCODING );
                if (encoding == null || encoding.length() == 0
                    || encoding.equals("8859-1") || encoding.equals("8859_1"))
                {
                    encoding = "ISO-8859-1";
                }

                OutputWrapper ow = new OutputWrapper();
                ow.setEncoding (encoding);
               
                context.put ("root", root.getRootElement());
                context.put ("xmlout", ow );
                context.put ("relativePath", getRelativePath(xmlFile));
                context.put ("treeWalk", new TreeWalker());
                context.put ("xpath", new XPathTool() );
                context.put ("escape", new Escape() );
                context.put ("date", new java.util.Date() );

                // only put this into the context if it exists.
                if (projectDocument != null)
                {
                    context.put ("project", projectDocument.getRootElement());
                }
               
                // Process the VSL template with the context and write out
                // the result as the outFile.
                writer = new BufferedWriter(new OutputStreamWriter(
View Full Code Here

           
            /*
             *  put the Vector into the context, and merge both
             */

            VelocityContext context = new VelocityContext();

            template1.merge(context, writer1);
            writer1.flush();
            writer1.close();
           
View Full Code Here

TOP

Related Classes of org.apache.flex.forks.velocity.VelocityContext

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.