Re: Trouble calling methods in a Struts 2 action

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thing is, FreeMarker is very flexible when it comes to building the
data-model (mostly done with so called object wrapping), and I don't
know what the Struts guys done. If they use the action object itself
to be the data-model, with some typical object wrapper setup the
public methods are visible. But then it seems they decided that they
will not be visible... they can do that, it's up to them. So maybe
it's better to ask them.


Friday, November 6, 2009, 9:22:36 PM, Christopher Maloof wrote:

> On 11/6/2009 2:44 PM, Daniel Dekany wrote: 
> Friday, November 6, 2009, 6:32:05 PM, Christopher Maloof wrote:
>
>   
> I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8.  It 
> mostly works great: my templates are retrieving bean information with no
> problem.  However, I can't figure out how to call methods defined in my
> action classes -- in fact I have no idea why it isn't working as I expected.
>
> If my action class looks like this:
>
> public class MyAction extends MyActionSupport {
>     public String getMyValue() {
>        return "hello";
>     }
>     public String myMethod() {
>        return "world";
>     }
> }
[snip]
> The template is mapped to the correct action, if that's what you're asking.  These things work:
> ${myValue}  (indirect access to bean getter)
> ${myValue.toUpperCase()}  (method call on object)
> <@s.property value="myMethod()"/>   (Struts tag calling a method)
>
> But these things don't:
> ${myMethod()}
> ${getMyValue()}  (plain method calls as described in the docs)
>
> Chris

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.