You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Manish <pr...@gmx.net> on 2004/11/08 07:46:35 UTC

file not found in #include #parse

How can I handle the condition gracefully that file specified by$fileName
does not exist in either -

#include($fileName)
#parse($fileName)

As of now, when the file is not found, it throws exception -

Unable to find resource '/user/profile123.htm'
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource '/user/profile123.htm'

TIA,
- Manish


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


Re: file not found in #include #parse

Posted by Shinobu Kawai <sh...@gmail.com>.
> > How can I handle the condition gracefully that file specified by$fileName
> > does not exist in either -
> > 
> > #include($fileName)
> > #parse($fileName)
> If you know the $fileName prior to the template handling, you can use
> the templateExists() method and check.  I believe in 1.4 they are called
> resourceExists().
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngine.html#templateExists(java.lang.String)
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/app/Velocity.html#templateExists(java.lang.String)
OTOH, it might be nice if we had properties like
    directive.include.throw.no.resource
    directive.parse.throw.no.resource

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: file not found in #include #parse

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Manish,

> BTW, if I have an HTML file, will this templateExists work for it?
It should.  If the HTML file can be found by the resource loaders, it
will return true.  Otherwise, false.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: file not found in #include #parse

Posted by Manish <pr...@gmx.net>.
> > resourceExists().
> >
http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngin
e.html#templateExists(java.lang.String)
> >
http://jakarta.apache.org/velocity/api/org/apache/velocity/app/Velocity.html
#templateExists(java.lang.String)
> OTOH, it might be nice if we had properties like
>     directive.include.throw.no.resource
>     directive.parse.throw.no.resource
>

I agree!!!
BTW, if I have an HTML file, will this templateExists work for it?

- Manish


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


Re: file not found in #include #parse

Posted by Shinobu Kawai <sh...@gmail.com>.
> > How can I handle the condition gracefully that file specified by$fileName
> > does not exist in either -
> > 
> > #include($fileName)
> > #parse($fileName)
> If you know the $fileName prior to the template handling, you can use
> the templateExists() method and check.  I believe in 1.4 they are called
> resourceExists().
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngine.html#templateExists(java.lang.String)
>     http://jakarta.apache.org/velocity/api/org/apache/velocity/app/Velocity.html#templateExists(java.lang.String)
OTOH, it might be nice if we had properties like
    directive.include.throw.no.resource
    directive.parse.throw.no.resource

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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


Re: file not found in #include #parse

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Manish,

> How can I handle the condition gracefully that file specified by$fileName
> does not exist in either -
> 
> #include($fileName)
> #parse($fileName)
If you know the $fileName prior to the template handling, you can use
the templateExists() method and check.  I believe in 1.4 they are called
resourceExists().
    http://jakarta.apache.org/velocity/api/org/apache/velocity/app/VelocityEngine.html#templateExists(java.lang.String)
    http://jakarta.apache.org/velocity/api/org/apache/velocity/app/Velocity.html#templateExists(java.lang.String)

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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