You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by ta...@mandic.com.br on 2003/06/25 18:10:42 UTC

I want to load templates from its full path.

Hi.

I have a question.

I have a class that control the velocity in my app. This class has a method that return
a Template. But, I want to load from its full pathname.

Like that:
public class VelocityControl
{
        private static VelocityEngine velocity;

        static
        {
                velocity = new VelocityEngine();

                velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "");
                velocity.setProperty(RuntimeConstants.PARSER_POOL_SIZE, "10");
                velocity.setProperty(RuntimeConstants.VM_MESSAGES_ON, "false");

                try
                {
                        velocity.init();
                }
                catch (Exception e)
                {
                        throw new ServiceError("Não foi possível inicializar o
Velocity.", e);
                }
        }

        public static Template getTemplate(String name) throws ParseErrorException,
ResourceNotFoundException, Exception
        {
                return velocity.getTemplate(name);
        }
}

So I made calls like:

VelocityControl.getTemplate("c:\anything\template.vm");
VelocityControl.getTemplate("/var/velocity/template.vm");
VelocityControl.getTemplate(sc.getRealPath("/WEB-INF/velocity/template.vm");

Thanks.
José Luiz Junior



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


I want to load templates from its full path.

Posted by Jose Luiz Juniot <ta...@mandic.com.br>.
    Please! Somebody helps me!

talkabout@mandic.com.br wrote:

>Hi.
>
>I have a question.
>
>I have a class that control the velocity in my app. This class has a method that return
>a Template. But, I want to load from its full pathname.
>
>Like that:
>public class VelocityControl
>{
>        private static VelocityEngine velocity;
>
>        static
>        {
>                velocity = new VelocityEngine();
>
>                velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "");
>                velocity.setProperty(RuntimeConstants.PARSER_POOL_SIZE, "10");
>                velocity.setProperty(RuntimeConstants.VM_MESSAGES_ON, "false");
>
>                try
>                {
>                        velocity.init();
>                }
>                catch (Exception e)
>                {
>                        throw new ServiceError("Não foi possível inicializar o
>Velocity.", e);
>                }
>        }
>
>        public static Template getTemplate(String name) throws ParseErrorException,
>ResourceNotFoundException, Exception
>        {
>                return velocity.getTemplate(name);
>        }
>}
>
>So I made calls like:
>
>VelocityControl.getTemplate("c:\anything\template.vm");
>VelocityControl.getTemplate("/var/velocity/template.vm");
>VelocityControl.getTemplate(sc.getRealPath("/WEB-INF/velocity/template.vm");
>
>Thanks.
>José Luiz Junior
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


I want to load templates from its full path.

Posted by Jose Luiz Junior <ju...@mandic.com.br>.
    Please! Somebody helps me!

talkabout@mandic.com.br wrote:

>Hi.
>
>I have a question.
>
>I have a class that control the velocity in my app. This class has a method that return
>a Template. But, I want to load from its full pathname.
>
>Like that:
>public class VelocityControl
>{
>        private static VelocityEngine velocity;
>
>        static
>        {
>                velocity = new VelocityEngine();
>
>                velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, "");
>                velocity.setProperty(RuntimeConstants.PARSER_POOL_SIZE, "10");
>                velocity.setProperty(RuntimeConstants.VM_MESSAGES_ON, "false");
>
>                try
>                {
>                        velocity.init();
>                }
>                catch (Exception e)
>                {
>                        throw new ServiceError("Não foi possível inicializar o
>Velocity.", e);
>                }
>        }
>
>        public static Template getTemplate(String name) throws ParseErrorException,
>ResourceNotFoundException, Exception
>        {
>                return velocity.getTemplate(name);
>        }
>}
>
>So I made calls like:
>
>VelocityControl.getTemplate("c:\anything\template.vm");
>VelocityControl.getTemplate("/var/velocity/template.vm");
>VelocityControl.getTemplate(sc.getRealPath("/WEB-INF/velocity/template.vm");
>
>Thanks.
>José Luiz Junior
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org