Re: Calling object method with no parameters without parentheses in template
Daniel Dekany <[email protected]> Wed, 16 Oct 2013 12:27:57 +0200
| Newsgroups | gmane.comp.web.freemarker.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Right now, this is possible with *configuring* DefaultObjectWrapper
(or whatever BeansWrapper-s):
http://stackoverflow.com/questions/18918141/freemarker-get-method-without-get/
With this ${Foo.bar} will work, but ${Foo.bar()} won't.
--
Thanks,
Daniel Dekany
Wednesday, October 16, 2013, 9:50:11 AM, Dmitry Bondarenko wrote:
> Hello, a question/request for Freemarker developers.
>
> We're using Freemarker in many projects developed by our company. We
> really like it, it fits well for our needs, but there is one thing we'd
> like to ask/request: calling object method with no parameters without
> parentheses in templates. E.g.:
>
> public class Foo {
>
> public int bar() { return 1; }
>
> }
>
> we'd like to call bar() without () inside templates:
>
> ${Foo.bar} instead of ${Foo.bar()}
>
> We tried to do that with DefaultObjectWrapper, but it wraps bar() into
> MethodTemplateModel and tells it could not be displayed in template.
>
> We'd like to have a Freemarker capability to call ${Foo.bar} (without
> parentheses) from template and display evaluated method results. (Just a
> clarification: we'd like to have this ability as Freemarker feature (out
> of the box), without need to implement custom ObjectWrapper for our needs).
>
> Cheers, Dmitry.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk