velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject Re: [ANNOUNCE] Velocity Engine 2.0 test build available
Date Tue, 08 Nov 2016 15:08:17 GMT
Unfortunately it only takes a String :

javax.servlet.ServletContext.getResourceAsStream(java.lang.String path)

So hopefully the encoding will be correct (Tomcat).

....Also I have noticed that if I call a method that has a null

eg $entry.filePath == null

$myPojo.thumbResource($entry.name, $entry.filePath)

I get an exception :

java.lang.IllegalArgumentException: wrong number of arguments at..

where before it used to work :

public String thumbResource(String name, String filePath) {
        if (StringUtils.isNotEmpty(name)
                && StringUtils.isNotEmpty(filePath)) {
            return getThumbResource(name, filePath);
        } else {
            return thumbResource();
        }
    }

Is there a workaround for this?

Thanks



On 8 November 2016 at 13:54, Sergiu Dumitriu <sergiu.dumitriu@gmail.com>
wrote:

> If you don't want surprises, you should also specify the encoding to
> use. I'm guessing that the files you're reading have a known encoding
> that's kept from the build into the distribution package, but you don't
> always have control over the system where it's installed.
>
> try {
>     return new BufferedReader(new
> InputStreamReader(servletContext.getResourceAsStream(path), "UTF-8"));
> } catch (UnsupportedEncodingException e) {
>     // This should never happen, UTF-8 is mandatory for a valid JVM
>     return null;
> }
>
> On 11/08/2016 07:13 AM, Greg Huber wrote:
> > Seems to be working OK.  Thanks.
> >
> > For the ResourceLoader changes I have been doing this :
> >
> > public  InputStream getResourceStream(String name)....
> >
> > return result = servletContext.getResourceAsStream(path);
> >
> > but now must use :
> >
> > public Reader getResourceReader(String name, String encoding)....
> >
> > return result = new BufferedReader(new InputStreamReader(
> >                             servletContext.getResourceAsStream(path)));
> >
> > Is this the most efficient way to the Reader class?  Seems a lot more
> > processing than just the InputStream??
> >
> >
> >
> >
> >
> > On 7 November 2016 at 10:06, Claude Brisson <claude@renegat.net> wrote:
> >
> >> The test build of Velocity Engine 2.0 is available.
> >>
> >> No determination as to the quality ('alpha,' 'beta,' or 'GA') of
> Velocity
> >> Engine 2.0 has been made, and at this time it is simply a "test build".
> We
> >> welcome any comments you may have, and will take all feedback into
> account
> >> if a quality vote is called for this build.
> >>
> >> Release notes:
> >>
> >> * https://dist.apache.org/repos/dist/dev/velocity/velocity-eng
> >> ine/2.0/release-notes.html
> >>
> >> Distribution:
> >>
> >>  * https://dist.apache.org/repos/dist/dev/velocity/velocity-engine/2.0/
> >>
> >> Maven 2 staging repository:
> >>
> >>  * https://repository.apache.org/content/repositories/orgapache
> >> velocity-1010/
> >>
> >> A vote regarding the quality of this test build will be initiated within
> >> the next couple of days.
> >>
> >>
> >> Regards,
> >>
> >>   Claude
> >>
> >>
> >>
> >
>
>
> --
> Sergiu Dumitriu
> http://purl.org/net/sergiu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message