You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Apache Wiki <wi...@apache.org> on 2005/05/06 22:59:32 UTC

[Jakarta-velocity Wiki] Update of "SilentParseInclude" by ShinobuKawaiYoshida

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-velocity Wiki" for change notification.

The following page has been changed by ShinobuKawaiYoshida:
http://wiki.apache.org/jakarta-velocity/SilentParseInclude

The comment on the change is:
add SilentParseInclude

New page:
{{{
package org.apache.velocity.tools.generic;

import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;

public class TemplateExistsTool implements ViewTool
{
    
    private VelocityEngine engine = null;
    
    public VelocityEngine getVelocityEngine()
    {
        return this.engine;
    }

    public void setVelocityEngine(VelocityEngine engine)
    {
        this.engine = engine;
    }

    public void init(Object obj)
    {
        // if ViewContext, try to retrieve a VelocityEngine for use
        if (obj instanceof ViewContext)
        {
            this.setVelocityEngine(((ViewContext) obj).getVelocityEngine());
        }
    }

    public boolean exists(String template)
    {
        if (this.engine == null)
        {
            return Velocity.resourceExists(template);
        }
        
        return this.engine.resourceExists(template);
    }

}
}}}

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