Re: File exists

[email protected] Thu, 9 Apr 2015 15:18:11 +0200 (CEST)
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <1372835709.867322070.1428585491659.JavaMail.root@zimbra65-e11.priv.proxad.net>
Unfortunately, I am using SOLR's implementation of Velocity, and don't know how to create FileHelpers in that context.


----- Mail original -----
De: "Will Glass-Husain" <[email protected]>
À: "Velocity Users List" <[email protected]>
Envoyé: Jeudi 9 Avril 2015 15:06:47
Objet: Re: File exists

You can't instantiate objects in Velocity for an arbitrary class.
 remember, Velocity is intended to be a templating, not a scripting
language.

Create a new class FileHelper which has a method "fileExists(string)".
Pass it into the context in your java code as a reference "fileHelper".
Then in your template call do

$fileHelper.fileExists("/mnt/etc/etc/etc/")

WILL

On Thu, Apr 9, 2015 at 5:58 AM, <[email protected]> wrote:

> Hello,
>
> does anyone know how to check if a file exists in Velocity?
>
> I have tried:
>
> #set ($exists = new
> File().exists("/mnt/xxxparnex01_pdf/PDF/IHT/${pdf_year_mon_v}/${pdf_day_v}/${pdf_name_page_number}_${pdf_name_page_type}_VIG.jpg")
> )
>
> to no avail.
>
> Cheers,
>
> Philippe
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>