Re: Trouble calling methods in a Struts 2 action
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
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";
> }
> }
>
> then ${myValue} or ${myValue.toUpperCase()} works fine, as does
> <@s.property value="myMethod()"/>, but ${myMethod()}results in a
> "Expression myMethod is undefined" error. The docs
> (http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_methodcall)
> seem to think this should be perfectly fine, as far as I can tell.
>
> Any idea why Freemarker isn't seeing the top-level action methods unless
> I use <@s.property>?
What's the data-model in Struts? It had to be the MyAction instance,
or else the methods will no be visible.
> Thanks for any help -
> Chris
>
>
> ------------------------------------------------------------------------------
> 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
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
--
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