struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Maloof <C_Mal...@mail.jci.tju.edu>
Subject Re: Trouble calling action methods from FreeMarker
Date Tue, 10 Nov 2009 17:46:48 GMT
Thanks!  I don't know what that's really doing, but it does work.  
Adding parameters to the methods is a bit wonky; it's very difficult to 
get the syntax right for
    ${stack.findValue("getScore('${st.name()}')")}
as opposed to the expected
    ${getScore(st.name())}

but it's something.

Maybe this should be added to 
http://struts.apache.org/2.x/docs/freemarker.html , assuming it's the 
intended behavior?  The question's been asked of the list at least a 
couple other times this year: 
http://markmail.org/message/4ordiw724kvdw5d6 and 
http://markmail.org/message/jjkic23knjk5tnpx.

Best,
Chris

On 11/10/2009 11:20 AM, Haroon Rafique wrote:
> Hi Chris,
>
> See reply embedded below...
>
> On Today at 10:32am, CM=>Christopher Maloof<C_Maloof@mail.jci.tju.edu>  wrote:
>
> CM>  I guess no one recognizes the problem.  Next question: Has anyone
> CM>  gotten this (calling action methods from FreeMarker tags) to work
> CM>  successfully? Just trying to figure out whether the correct approach
> CM>  is to hammer on my configuration somehow, or to file a bug.
> CM>
> CM>  Thanks,
> CM>  Chris
> CM>
> CM>  On 11/9/2009 10:13 AM, Christopher Maloof wrote:
> CM>  >  I'm just starting to use FreeMarker (2.3.15) with Struts 2.1.8.  It mostly
> CM>  >  works fine: my templates are retrieving bean information with no problem.
> CM>  >  However, I can't figure out how to call methods defined in my action
> CM>  >  classes.
> CM>  >
> CM>  >  If my action class looks like this:
> CM>  >
> CM>  >  public class MyAction extends MyActionSupport {
> CM>  >     public String getMyValue() {
> CM>  >        return "hello";
> CM>  >     }
> CM>  >     public String myMethod() {
> CM>  >        return "world";
> CM>  >     }
> CM>  >  }
> CM>  >
> CM>  >  Then these things work:
> CM>  >  ${myValue}  (indirect access to bean getter)
> CM>  >  ${myValue.toUpperCase()}  (method call on object)
> CM>  >  <@s.property value="myMethod()"/>    (Struts tag calling a method)
> CM>  >
> CM>  >  But these things don't:
> CM>  >  ${myMethod()}
> CM>  >  ${getMyValue()}  (plain method calls as described in the docs)
> CM>  >
>
>
> Try:
>
> ${stack.findValue("getMyValue()")}
> ${stack.findValue("myMethod()")}
>
> Later,
> --
> Haroon Rafique
> <haroon.rafique@utoronto.ca>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message